[galeon] Get rid of libbonobo



commit 382fe553014a48da588515ce2010e09b1f093112
Author: Fabio Bonelli <fabiob src gnome org>
Date:   Wed May 12 18:37:30 2010 +0200

    Get rid of libbonobo
    
    Galeon uses D-Bus now, mainly ported from Epiphany. Support for GTM was
    dropped as well.

 GNOME_Galeon_Automation.server.in   |   20 --
 Makefile.am                         |   17 +-
 configure.in                        |   25 +--
 galeon-service.xml                  |   18 ++
 idl/.cvsignore                      |    1 -
 idl/GaleonAutomation.idl            |   42 ---
 idl/Gtm.idl                         |    6 -
 org.gnome.Galeon.service.in         |    3 +
 src/Makefile.am                     |   87 ++++--
 src/galeon-activation.c             |  105 +++++++
 src/galeon-activation.h             |   44 +++
 src/galeon-automation.c             |  473 ------------------------------
 src/galeon-automation.h             |   52 ----
 src/galeon-dbus.c                   |  548 +++++++++++++++++++++++++++++++++++
 src/galeon-dbus.h                   |   91 ++++++
 src/galeon-main.c                   |  402 ++++++++++++++------------
 src/{session.c => galeon-session.c} |  252 ++++++++++++++++-
 src/{session.h => galeon-session.h} |   14 +-
 src/galeon-shell.c                  |   50 +---
 src/galeon-shell.h                  |    4 +-
 src/galeon-sidebars.c               |    2 +-
 src/galeon-window-menu.c            |    2 +-
 utils/Makefile.am                   |   13 +-
 utils/galeon-marshal.list           |    1 +
 utils/gul-download.c                |   47 +---
 25 files changed, 1385 insertions(+), 934 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 813fb6e..6ba3644 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,15 +18,19 @@ Application_in_files = galeon.desktop.in
 Application_DATA = $(Application_in_files:.desktop.in=.desktop) 
 @INTLTOOL_DESKTOP_RULE@
 
-server_in_files = GNOME_Galeon_Automation.server.in
-server_DATA = GNOME_Galeon_Automation.server
-serverdir = $(libdir)/bonobo/servers
- INTLTOOL_SERVER_RULE@
-
 schemadir = $(GCONF_SCHEMA_FILE_DIR)
 schema_DATA = galeon.schemas
 @INTLTOOL_SCHEMAS_RULE@
 
+# Dbus service file
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.Galeon.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+# Rule to make the service file with bindir expanded
+$(service_DATA): $(service_in_files) Makefile
+	@sed -e "s|\ bindir\@|$(bindir)|" $< > $@
+
 if GCONF_SCHEMAS_INSTALL
 install-data-local:
 	for p in $(schema_DATA) ; do \
@@ -38,19 +42,18 @@ EXTRA_DIST = \
 	COPYING.README FAQ galeon.spec.in \
 	galeon.spec \
 	$(Application_in_files) \
-	$(server_in_files) \
 	galeon-config-tool \
 	intltool-extract.in \
 	intltool-merge.in \
 	intltool-update.in \
 	galeon.schemas.in \
+	galeon-service.xml \
 	INSTALL.in \
 	README.ExtraPrefs
 
 DISTCLEANFILES = \
 	$(Application_DATA)	\
 	$(schema_DATA)		\
-	$(server_DATA)		\
 	intltool-extract	\
 	intltool-merge		\
 	intltool-update
diff --git a/configure.in b/configure.in
index 0de87cc..74a184b 100644
--- a/configure.in
+++ b/configure.in
@@ -19,9 +19,6 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 dnl put the ACLOCAL flags in the Makefile
 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
 
-BONOBO_ACTIVATION_REQUIRED=2.0.0
-LIBBONOBO_REQUIRED=2.0.0
-LIBBONOBOUI_REQUIRED=2.1.1
 LIBGLADE_REQUIRED=2.3.1
 LIBGNOMEUI_REQUIRED=2.5.2
 LIBXML_REQUIRED=2.6.6
@@ -29,15 +26,11 @@ GCONF_REQUIRED=2.3.2
 GLIB_REQUIRED=2.4.0
 GNOME_VFS_REQUIRED=2.0.0
 GTK_REQUIRED=2.12.0
-ORBIT_REQUIRED=2.0.0
 SCROLLKEEPER_REQUIRED=0.1.4
 
 dnl Only for gnome-vfs > 2.9.2
 GNOME_DESKTOP_REQUIRED=2.9.91
 
-AC_SUBST(BONOBO_ACTIVATION_REQUIRED)
-AC_SUBST(LIBBONOBO_REQUIRED)
-AC_SUBST(LIBBONOBOUI_REQUIRED)
 AC_SUBST(LIBGLADE_REQUIRED)
 AC_SUBST(LIBGNOMEUI_REQUIRED)
 AC_SUBST(LIBXML_REQUIRED)
@@ -45,7 +38,6 @@ AC_SUBST(GCONF_REQUIRED)
 AC_SUBST(GLIB_REQUIRED)
 AC_SUBST(GNOME_VFS_REQUIRED)
 AC_SUBST(GTK_REQUIRED)
-AC_SUBST(ORBIT_REQUIRED)
 AC_SUBST(SCROLLKEEPER_REQUIRED)
 
 AC_ENABLE_SHARED(yes)
@@ -56,7 +48,7 @@ if test "x$enable_maintainer_mode" = "xyes"; then
   AC_DEFINE(MAINTAINER_MODE, 1, [Define to 1 if you wish to enable 'maintainer-only' behavior.])
   disable_werror=no
   enable_debug=yes
-  AM_CPPFLAGS="-DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGCONF_DISABLE_DEPRECATED -DGNOME_VFS_DISABLE_DEPRECATED -DBONOBO_UI_DISABLE_DEPRECATED -DBONOBO_DISABLE_DEPRECATED -DLIBGLADE_DISABLE_DEPRECATED -DPANGO_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED"
+  AM_CPPFLAGS="-DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGCONF_DISABLE_DEPRECATED -DGNOME_VFS_DISABLE_DEPRECATED -DLIBGLADE_DISABLE_DEPRECATED -DPANGO_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGNOME_DISABLE_DEPRECATED"
 else
   disable_werror=yes
   AM_CPPFLAGS=
@@ -74,6 +66,8 @@ AC_HEADER_STDC
 AC_PROG_INTLTOOL
 AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
+AC_PATH_PROG([DBUS_BINDING_TOOL],[dbus-binding-tool],[no])
+
 GNOME_DEBUG_CHECK
 
 dnl ******************************
@@ -97,15 +91,11 @@ PKG_CHECK_MODULES(GALEON_DEPENDENCY, \
 		  gtk+-unix-print-2.0 >= $GTK_REQUIRED \
 		  libxml-2.0 >= $LIBXML_REQUIRED \
 		  libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \
-		  libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED \
 		  libglade-2.0 >= $LIBGLADE_REQUIRED \
-		  libbonobo-2.0 >= $LIBBONOBO_REQUIRED \
 		  glib-2.0 >= $GLIB_REQUIRED \
 		  gobject-2.0 >= $GLIB_REQUIRED \
 		  gdk-pixbuf-2.0 >= $GTK_REQUIRED \
 		  gdk-2.0 >= $GTK_REQUIRED \
-		  bonobo-activation-2.0 >= $BONOBO_ACTIVATION_REQUIRED \
-		  ORBit-2.0 >= $ORBIT_REQUIRED \
 		  gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED\
 		  gnome-vfs-module-2.0 >= $GNOME_VFS_REQUIRED\
 		  gconf-2.0 >= $GCONF_REQUIRED \
@@ -114,15 +104,6 @@ PKG_CHECK_MODULES(GALEON_DEPENDENCY, \
 AC_SUBST(GALEON_DEPENDENCY_CFLAGS)
 AC_SUBST(GALEON_DEPENDENCY_LIBS)
 
-ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`"
-AC_SUBST(ORBIT_IDL)
-
-LIBBONOBO_IDL="`$PKG_CONFIG --variable=idldir libbonobo-2.0`"
-AC_SUBST(LIBBONOBO_IDL)
-
-BONOBO_ACTIVATION_IDL="`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`"
-AC_SUBST(BONOBO_ACTIVATION_IDL)
-
 dnl ################
 dnl GtkHTML checking
 dnl ################
diff --git a/galeon-service.xml b/galeon-service.xml
new file mode 100644
index 0000000..19341a5
--- /dev/null
+++ b/galeon-service.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/org/gnome/Galeon">
+	<interface name="org.gnome.Galeon">
+		<method name="loadSession">
+			<arg type="s" name="SessionFilename" direction="in" />
+			<arg type="u" name="Timestamp" direction="in" />
+		</method>
+		<method name="loadURIList">
+			<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="galeon_activation_load_uri_list" />
+			<arg type="as" name="URIs" direction="in" />
+			<arg type="s" name="Options" direction="in" />
+			<arg type="u" name="Timestamp" direction="in" />
+		</method>
+		<method name="quit">
+			<arg type="b" name="ExitServer" direction="in" />
+		</method>
+	</interface>
+</node>
diff --git a/org.gnome.Galeon.service.in b/org.gnome.Galeon.service.in
new file mode 100644
index 0000000..a63cf1e
--- /dev/null
+++ b/org.gnome.Galeon.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.galeon
+Exec= bindir@/galeon
diff --git a/src/Makefile.am b/src/Makefile.am
index 2aeb89a..ff5edce 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,21 +17,14 @@ galeon_LINK = $(QUIET_LD) $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS
               --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS)         \
               $(galeon_LDFLAGS) $(LDFLAGS) -o $@
 
-galeon_automation_interface_idl_sources = \
-	GaleonAutomation-common.c	  \
-	GaleonAutomation-stubs.c	  \
-	GaleonAutomation-skels.c	  \
-	GaleonAutomation.h		
-
-nodist_galeon_SOURCES =					\
-	$(galeon_automation_interface_idl_sources)
-
 galeon_SOURCES = 				    	\
 	statusbar.c					\
 	statusbar.h					\
 	galeon-main.c					\
-	galeon-automation.c				\
-	galeon-automation.h				\
+	galeon-activation.c 				\
+	galeon-activation.h                             \
+	galeon-dbus.c 					\
+	galeon-dbus.h 					\
 	galeon-language-editor.c			\
 	galeon-language-editor.h			\
 	galeon-prefs-dialog.c				\
@@ -70,8 +63,8 @@ galeon_SOURCES = 				    	\
 	galeon-spinner.h			        \
 	ppview-toolbar.c				\
 	ppview-toolbar.h				\
-	session.c					\
-	session.h					\
+	galeon-session.c				\
+	galeon-session.h				\
 	page-info-dialog.c				\
 	page-info-dialog.h				\
 	pdm-dialog.c					\
@@ -126,6 +119,10 @@ galeon_SOURCES = 				    	\
 	migrate.h					\
 	gcc2abi.cpp
 
+nodist_galeon_SOURCES = \
+	galeon-type-builtins.c 				\
+	galeon-type-builtins.h
+
 galeon_LDADD = \
 	$(top_builddir)/embed/libembed.la \
 	$(top_builddir)/mozilla/libmozillaembed.la \
@@ -147,16 +144,6 @@ if ENABLE_GTKHTML_EMBED
 gtkhtmlembed_libs = $(top_builddir)/gtkhtml/libgtkhtmlembed.la
 endif
 
-BUILT_SOURCES=	\
-        GaleonAutomation.h GaleonAutomation-common.c GaleonAutomation-stubs.c GaleonAutomation-skels.c
-
-CLEANFILES = $(BUILT_SOURCES)
-
-GaleonAutomation-common.c GaleonAutomation-stubs.c GaleonAutomation-skels.c GaleonAutomation.h: $(top_srcdir)/idl/GaleonAutomation.idl
-	$(ORBIT_IDL) -I $(LIBBONOBO_IDL) -I $(BONOBO_ACTIVATION_IDL) $(top_srcdir)/idl/GaleonAutomation.idl
-
-EXTRA_DIST = $(top_srcdir)/idl/GaleonAutomation.idl
-
 # Quiet compilation
 LIBTOOL = $(SHELL) $(top_builddir)/libtool $(LIBTOOL_ARG)
 
@@ -167,3 +154,57 @@ LIBTOOL = $(SHELL) $(top_builddir)/libtool $(LIBTOOL_ARG)
 .cpp.o:
 	$(QUIET_CPP)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
 	$(Q)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+
+galeon-type-builtins.c: stamp-galeon-type-builtins.c Makefile
+	@true
+stamp-galeon-type-builtins.c: Makefile galeon-dbus.c galeon-dbus.h
+	$(GLIB_MKENUMS)                                                            \
+		--fhead "#include \"galeon-type-builtins.h\"\n\n"                  \
+		--fprod "\n/* enumerations from \"@filename \" */"                 \
+		--fprod "\n#include \"@filename \""                                \
+		--vhead "GType\n enum_name@_get_type (void)\n{\n"                  \
+		--vhead "  static GType type = 0;\n\n"                             \
+		--vhead "  if (G_UNLIKELY (type == 0))\n  {\n"                     \
+		--vhead "    static const G Type@Value _ enum_name@_values[] = {"  \
+		--vprod "      { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+		--vtail "      { 0, NULL, NULL }\n    };\n\n"                      \
+		--vtail "    type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n  }\n\n" \
+		--vtail "  return type;\n}\n\n"                                    \
+		$(filter-out $<,$^) > xgen-$(@F)                                   \
+	&& ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \
+	&& rm -f xgen-$(@F)                                                       \
+	&& echo timestamp > $(@F)
+
+galeon-type-builtins.h: stamp-galeon-type-builtins.h Makefile
+	@true
+stamp-galeon-type-builtins.h: Makefile galeon-dbus.c galeon-dbus.h
+	$(GLIB_MKENUMS)                                                            \
+		--fhead "#ifndef GALEON_LIB_TYPE_BUILTINS_H\n"                     \
+		--fhead "#define GALEON_LIB_TYPE_BUILTINS_H 1\n\n"                 \
+		--fhead "#include <glib-object.h>\n\n"                             \
+		--fhead "G_BEGIN_DECLS\n\n"                                        \
+		--ftail "G_END_DECLS\n\n"                                          \
+		--ftail "#endif /* GALEON_LIB_TYPE_BUILTINS_H */\n"                \
+		--fprod "\n/* --- @filename@ --- */"                               \
+		--eprod "#define GALEON_TYPE_ ENUMSHORT@ @enum_name _get_type()\n" \
+		--eprod "GType @enum_name _get_type (void);\n"                     \
+		$(filter-out $<,$^) > xgen-$(@F) \
+	&& ( cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%) ) \
+	&&  rm -f xgen-$(@F)                                                      \
+	&&  echo timestamp > $(@F)
+
+galeon-dbus-server-bindings.h: stamp-galeon-dbus-server-bindings.h
+	@true
+stamp-galeon-dbus-server-bindings.h: $(top_srcdir)/galeon-service.xml Makefile
+	$(DBUS_BINDING_TOOL) --prefix=galeon_activation --mode=glib-server $< > xgen-$(@F) \
+	&& ( cmp -s xgen-$(@F) $(@F:stamp-%=%) ||  cp xgen-$(@F) $(@F:stamp-%=%) ) \
+	&&  rm -f xgen-$(@F)                                                           \
+	&&  echo timestamp > $(@F)
+
+galeon-dbus-client-bindings.h: stamp-galeon-dbus-client-bindings.h
+	@true
+stamp-galeon-dbus-client-bindings.h: $(top_srcdir)/galeon-service.xml Makefile
+	$(DBUS_BINDING_TOOL) --prefix=galeon_activation --mode=glib-client $< > xgen-$(@F) \
+	&& ( cmp -s xgen-$(@F) $(@F:stamp-%=%) ||  cp xgen-$(@F) $(@F:stamp-%=%) ) \
+	&&  rm -f xgen-$(@F)                                                       \
+	&&  echo timestamp > $(@F)
diff --git a/src/galeon-activation.c b/src/galeon-activation.c
new file mode 100644
index 0000000..4f8e300
--- /dev/null
+++ b/src/galeon-activation.c
@@ -0,0 +1,105 @@
+/*
+ *  Copyright © 2005 Gustavo Gama
+ *
+ *  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 2, 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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "galeon-activation.h"
+
+#include "galeon-shell.h"
+#include "galeon-session.h"
+#include "eel-gconf-extensions.h"
+#include "galeon-debug.h"
+
+static gboolean
+session_queue_command (SessionResumeType  command,
+		       GValue            *arg,
+		       char             **args,
+		       guint              startup_id,
+		       GError           **error)
+{
+	GaleonShell *shell;
+	Session *session;
+
+	shell = galeon_shell_get_default ();
+	if (shell == NULL)
+	{
+		g_set_error (error,
+			     g_quark_from_static_string ("galeon-activation-error"),
+			     0, 
+			     "Shutting down." /* FIXME i18n & better string */);
+		return FALSE;
+	}
+
+	session = galeon_shell_get_session (galeon_shell_get_default());
+	g_assert (session != NULL);
+
+	galeon_session_queue_command (session, command, arg, args,
+				     (guint32) startup_id, FALSE);
+
+	return TRUE;
+}
+
+gboolean
+galeon_activation_load_uri_list (GaleonDbus  *galeon_dbus,
+		                 char       **uris,
+		                 char        *options,
+	                         guint        startup_id,
+	                         GError     **error)
+{
+	GValue new_options = { 0 };
+
+        g_value_init (&new_options, G_TYPE_STRING);
+        g_value_set_string (&new_options,
+                            g_strconcat (options, "external,", NULL));        
+
+	return session_queue_command (GALEON_SESSION_CMD_OPEN_URIS,
+				      &new_options, uris, startup_id, error);
+}
+
+gboolean
+galeon_activation_load_session (GaleonDbus *galeon_dbus,
+	                        char       *session_name,
+	                        guint       startup_id,
+	                        GError    **error)
+{
+        GValue value = { 0 };
+
+        g_value_init (&value, G_TYPE_STRING);
+        g_value_set_string (&value, session_name);
+
+	return session_queue_command (GALEON_SESSION_CMD_LOAD_SESSION,
+				      &value, NULL, startup_id, error);
+}
+
+gboolean
+galeon_activation_quit (GaleonDbus *galeon_dbus,
+                        gboolean    exit_server,
+                        GError    **error)
+{
+        GValue value = { 0 };
+
+        g_value_init (&value, G_TYPE_BOOLEAN);
+        g_value_set_boolean (&value, exit_server);
+
+        return session_queue_command (GALEON_SESSION_QUIT,
+                                      &value,
+                                      NULL,
+                                      0,
+                                      error);
+}
diff --git a/src/galeon-activation.h b/src/galeon-activation.h
new file mode 100644
index 0000000..cbad2e0
--- /dev/null
+++ b/src/galeon-activation.h
@@ -0,0 +1,44 @@
+/*
+ *  Copyright © 2005 Gustavo Gama
+ *
+ *  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 2, 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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GALEON_ACTIVATION_H
+#define GALEON_ACTIVATION_H
+
+#include "galeon-dbus.h"
+
+G_BEGIN_DECLS
+
+/* activation handlers */
+gboolean galeon_activation_load_uri_list         (GaleonDbus *galeon_dbus,
+						  char **uris,
+						  char *options,
+						  guint startup_id,
+						  GError **error);
+
+gboolean galeon_activation_load_session		 (GaleonDbus *galeon_dbus,
+						  char *session_name,
+						  guint user_time,
+						  GError **error);
+
+gboolean galeon_activation_quit                  (GaleonDbus *galeon_dbus,
+						  gboolean exit_server,
+						  GError **error);
+G_END_DECLS
+
+#endif 
diff --git a/src/galeon-dbus.c b/src/galeon-dbus.c
new file mode 100644
index 0000000..fd4aa04
--- /dev/null
+++ b/src/galeon-dbus.c
@@ -0,0 +1,548 @@
+/*
+ *  Copyright © 2004, 2005 Jean-François Rameau
+ *  Copyright © 2006 Christian Persch
+ *
+ *  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 2, 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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "galeon-dbus.h"
+#include "galeon-type-builtins.h"
+#include "galeon-marshal.h"
+#include "galeon-activation.h"
+#include "galeon-dbus-server-bindings.h"
+
+#include <string.h>
+#include <dbus/dbus-glib-bindings.h>
+
+/* dbus 0.6 API change */
+#ifndef DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT
+#define DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT 0
+#endif
+
+/* dbus < 0.6 compat */
+#ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE
+#define DBUS_NAME_FLAG_DO_NOT_QUEUE 0
+#endif
+
+/* Galeon's DBUS ids */
+#define DBUS_GALEON_SERVICE	"org.gnome.Galeon"
+#define DBUS_GALEON_PATH		"/org/gnome/Galeon"
+#define DBUS_GALEON_INTERFACE	"org.gnome.Galeon"
+
+#define RECONNECT_DELAY	3 /* seconds */
+
+#define GALEON_DBUS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), GALEON_TYPE_DBUS, GaleonDbusPrivate))
+
+struct _GaleonDbusPrivate
+{
+	DBusGConnection *session_bus;
+	DBusGConnection *system_bus;
+	guint session_reconnect_timeout_id;
+	guint system_reconnect_timeout_id;
+	guint is_session_service_owner : 1;
+	guint register_name : 1;
+};
+
+enum
+{
+	CONNECTED,
+	DISCONNECTED,
+	LAST_SIGNAL
+};
+
+enum
+{
+	PROP_0,
+	PROP_CLAIM_NAME
+};
+
+static GaleonDbus *galeon_dbus_instance;
+
+static guint signals[LAST_SIGNAL];
+GQuark galeon_dbus_error_quark;
+
+/* Filter signals form session bus */
+static DBusHandlerResult session_filter_func (DBusConnection *connection,
+				              DBusMessage *message,
+				              void *user_data);
+/* Filter signals from system bus */
+static DBusHandlerResult system_filter_func (DBusConnection *connection,
+				             DBusMessage *message,
+				             void *user_data);
+
+/* Both  connect to their respective bus */
+static gboolean galeon_dbus_connect_to_session_bus (GaleonDbus*, GError**);
+static gboolean galeon_dbus_connect_to_system_bus  (GaleonDbus*, GError**);
+
+/* implementation of the DBUS helpers */
+
+static gboolean
+galeon_dbus_connect_to_session_bus_cb (gpointer user_data)
+{
+	GaleonDbus *dbus = GALEON_DBUS (user_data);
+
+	if (!galeon_dbus_connect_to_session_bus (dbus, NULL))
+	{
+		/* try again */
+		return TRUE;
+	}
+
+	dbus->priv->session_reconnect_timeout_id = 0;
+
+	/* we're done */
+	return FALSE;
+}
+
+static gboolean
+galeon_dbus_connect_to_system_bus_cb (gpointer user_data)
+{
+	GaleonDbus *dbus = GALEON_DBUS (user_data);
+
+	if (!galeon_dbus_connect_to_system_bus (dbus, NULL))
+	{
+		/* try again */
+		return TRUE;
+	}
+
+	dbus->priv->system_reconnect_timeout_id = 0;
+
+	/* we're done */
+	return FALSE;
+}
+
+static DBusHandlerResult
+session_filter_func (DBusConnection *connection,
+	     	     DBusMessage *message,
+	     	     void *user_data)
+{
+	GaleonDbus *galeon_dbus = GALEON_DBUS (user_data);
+	GaleonDbusPrivate *priv = galeon_dbus->priv;
+
+	if (dbus_message_is_signal (message,
+				    DBUS_INTERFACE_LOCAL,
+				    "Disconnected"))
+	{
+		// LOG ("GaleonDbus disconnected from session bus");
+
+		dbus_g_connection_unref (priv->session_bus);
+		priv->session_bus = NULL;
+
+		g_signal_emit (galeon_dbus, signals[DISCONNECTED], 0, GALEON_DBUS_SESSION);
+
+		/* try to reconnect later ... */
+		priv->session_reconnect_timeout_id =
+			g_timeout_add_seconds (RECONNECT_DELAY,
+				       (GSourceFunc) galeon_dbus_connect_to_session_bus_cb,
+				       galeon_dbus);
+
+		return DBUS_HANDLER_RESULT_HANDLED;
+	}
+
+	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static DBusHandlerResult
+system_filter_func (DBusConnection *connection,
+	     	    DBusMessage *message,
+	     	    void *user_data)
+{
+	GaleonDbus *galeon_dbus = GALEON_DBUS (user_data);
+	GaleonDbusPrivate *priv = galeon_dbus->priv;
+
+	// LOG ("GaleonDbus filtering message from system bus");
+
+	if (dbus_message_is_signal (message,
+				    DBUS_INTERFACE_LOCAL,
+				    "Disconnected"))
+	{
+		// LOG ("GaleonDbus disconnected from system bus");
+
+		dbus_g_connection_unref (priv->system_bus);
+		priv->system_bus = NULL;
+
+		g_signal_emit (galeon_dbus, signals[DISCONNECTED], 0, GALEON_DBUS_SYSTEM);
+
+		/* try to reconnect later ... */
+		priv->system_reconnect_timeout_id =
+			g_timeout_add_seconds (RECONNECT_DELAY,
+				       (GSourceFunc) galeon_dbus_connect_to_system_bus_cb,
+				       galeon_dbus);
+
+		return DBUS_HANDLER_RESULT_HANDLED;
+	}
+
+	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static gboolean
+galeon_dbus_connect_to_system_bus (GaleonDbus *galeon_dbus,
+				 GError **error)
+{
+	GaleonDbusPrivate *priv = galeon_dbus->priv;
+
+	// LOG ("GaleonDbus connecting to system DBUS");
+
+	priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
+	if (priv->system_bus == NULL)
+	{
+		g_warning ("Unable to connect to system bus: %s", error ? (*error)->message : "");
+		return FALSE;
+	}
+
+	if (dbus_g_connection_get_connection (priv->system_bus) == NULL)
+	{
+		g_warning ("DBus connection is null");
+		g_set_error (error,
+			     GALEON_DBUS_ERROR_QUARK,
+			     0,
+			     "DBus connection is NULL");
+		return FALSE;
+	}
+
+	dbus_connection_set_exit_on_disconnect 
+		(dbus_g_connection_get_connection (priv->system_bus),
+		 FALSE);
+
+	dbus_connection_add_filter
+		(dbus_g_connection_get_connection (priv->system_bus),
+		 system_filter_func, galeon_dbus, NULL);
+
+	g_signal_emit (galeon_dbus, signals[CONNECTED], 0, GALEON_DBUS_SYSTEM);
+
+	return TRUE;
+}
+
+static gboolean
+galeon_dbus_connect_to_session_bus (GaleonDbus *galeon_dbus,
+				  GError **error)
+{
+	GaleonDbusPrivate *priv = galeon_dbus->priv;
+	DBusGProxy *proxy;
+	guint request_ret;
+	
+	// LOG ("GaleonDbus connecting to session DBUS");
+
+	/* Init the DBus connection */
+	priv->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, error);
+	if (priv->session_bus == NULL)
+	{
+		g_warning("Unable to connect to session bus: %s", error && *error ? (*error)->message : "");
+		return FALSE;
+	}
+
+	dbus_connection_set_exit_on_disconnect 
+		(dbus_g_connection_get_connection (priv->session_bus),
+		 FALSE);
+
+	dbus_connection_add_filter
+		(dbus_g_connection_get_connection (priv->session_bus),
+		 session_filter_func, galeon_dbus, NULL);
+
+	if (priv->register_name == FALSE) return TRUE;
+
+	dbus_g_object_type_install_info (GALEON_TYPE_DBUS,
+					 &dbus_glib_galeon_activation_object_info);
+
+	/* Register DBUS path */
+	dbus_g_connection_register_g_object (priv->session_bus,
+					     DBUS_GALEON_PATH,
+					     G_OBJECT (galeon_dbus));
+
+	/* Register the service name, the constant here are defined in dbus-glib-bindings.h */
+	proxy = dbus_g_proxy_new_for_name (priv->session_bus,
+					   DBUS_SERVICE_DBUS,
+					   DBUS_PATH_DBUS,
+					   DBUS_INTERFACE_DBUS);
+
+	if (!org_freedesktop_DBus_request_name (proxy,
+						DBUS_GALEON_SERVICE,
+						DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT |
+						DBUS_NAME_FLAG_DO_NOT_QUEUE,
+						&request_ret, error))
+	{
+		/* We have a BIG problem! */
+		g_warning ("RequestName failed: %s\n", error ? (*error)->message : "");
+		return FALSE;
+	}
+
+	if (request_ret == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ||
+	    request_ret == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
+	{
+		priv->is_session_service_owner = TRUE;
+	}
+	else if (request_ret == DBUS_REQUEST_NAME_REPLY_EXISTS ||
+		 request_ret == DBUS_REQUEST_NAME_REPLY_IN_QUEUE)
+	{
+		priv->is_session_service_owner = FALSE;
+	}
+
+	// LOG ("Instance is %ssession bus owner.", priv->is_session_service_owner ? "" : "NOT ");
+
+	g_object_unref (proxy);
+
+	return TRUE;
+}
+
+/* Public methods */
+
+static void
+galeon_dbus_shutdown (GaleonDbus *dbus)
+{
+	GaleonDbusPrivate *priv = dbus->priv;
+
+	// LOG ("GaleonDbus shutdown");
+
+	if (priv->session_reconnect_timeout_id != 0)
+	{
+		g_source_remove (priv->session_reconnect_timeout_id);
+		priv->session_reconnect_timeout_id = 0;
+	}
+
+	if (priv->system_reconnect_timeout_id != 0)
+	{
+		g_source_remove (priv->system_reconnect_timeout_id);
+		priv->system_reconnect_timeout_id = 0;
+	}
+
+	if (priv->session_bus)
+	{
+		dbus_connection_remove_filter
+			(dbus_g_connection_get_connection (priv->session_bus),
+			 session_filter_func, dbus);
+		dbus_g_connection_unref (priv->session_bus);
+		priv->session_bus = NULL;
+	}
+
+        if (priv->system_bus)
+	{
+		dbus_connection_remove_filter
+			(dbus_g_connection_get_connection (priv->system_bus),
+			 system_filter_func, dbus);
+		dbus_g_connection_unref (priv->system_bus);
+		priv->system_bus = NULL;
+	}
+}
+
+/* Class implementation */
+
+G_DEFINE_TYPE (GaleonDbus, galeon_dbus, G_TYPE_OBJECT)
+
+static void
+galeon_dbus_get_property (GObject *object,
+			guint prop_id,
+		 	GValue *value,
+			GParamSpec *pspec)
+{
+	/* no readable properties */
+	g_return_if_reached ();
+}
+
+static void
+galeon_dbus_set_property (GObject *object,
+			guint prop_id,
+			const GValue *value,
+			GParamSpec *pspec)
+{
+	GaleonDbus *dbus = GALEON_DBUS (object);
+	GaleonDbusPrivate *priv = dbus->priv;
+
+	switch (prop_id)
+	{
+		case PROP_CLAIM_NAME:
+			priv->register_name = g_value_get_boolean (value);
+			break;
+	}
+}
+
+static void
+galeon_dbus_finalize (GObject *object)
+{
+	GaleonDbus *dbus = GALEON_DBUS (object);
+
+	/* Have to do this after the object's weak ref notifiers have
+	 * been called, see https://bugs.freedesktop.org/show_bug.cgi?id=5688
+	 */
+	galeon_dbus_shutdown (dbus);
+
+	// LOG ("GaleonDbus finalised");
+
+	G_OBJECT_CLASS (galeon_dbus_parent_class)->finalize (object);
+}
+
+static void
+galeon_dbus_init (GaleonDbus *dbus)
+{
+	dbus->priv = GALEON_DBUS_GET_PRIVATE (dbus);
+
+	// LOG ("GaleonDbus initialising");
+}
+
+static void
+galeon_dbus_class_init (GaleonDbusClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->get_property = galeon_dbus_get_property;
+	object_class->set_property = galeon_dbus_set_property;
+	object_class->finalize = galeon_dbus_finalize;
+
+	signals[CONNECTED] =
+		g_signal_new ("connected",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GaleonDbusClass, connected),
+			      NULL, NULL,
+			      galeon_marshal_VOID__ENUM,
+			      G_TYPE_NONE,
+			      1,
+			      GALEON_TYPE_DBUS_BUS);
+
+	signals[DISCONNECTED] =
+		g_signal_new ("disconnected",
+			      G_OBJECT_CLASS_TYPE (object_class),
+			      G_SIGNAL_RUN_FIRST,
+			      G_STRUCT_OFFSET (GaleonDbusClass, disconnected),
+			      NULL, NULL,
+			      galeon_marshal_VOID__ENUM,
+			      G_TYPE_NONE,
+			      1,
+			      GALEON_TYPE_DBUS_BUS);
+
+	g_object_class_install_property
+		(object_class,
+		 PROP_CLAIM_NAME,
+		 g_param_spec_boolean ("register-name",
+				       "register-name",
+				       "register-name",
+				       TRUE,
+				       G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+	g_type_class_add_private (object_class, sizeof(GaleonDbusPrivate));
+}
+
+GaleonDbus *
+galeon_dbus_get_default (void)
+{
+	g_assert (galeon_dbus_instance != NULL);
+
+	return galeon_dbus_instance;
+}
+
+/**
+ * galeon_dbus_get_bus:
+ * @dbus:
+ * @kind:
+ * 
+ * Returns: the #DBusGConnection for the @kind DBUS, or %NULL
+ * if a connection could not be established.
+ */
+DBusGConnection *
+galeon_dbus_get_bus (GaleonDbus *dbus,
+		   GaleonDbusBus kind)
+{
+	GaleonDbusPrivate *priv = dbus->priv;
+	DBusGConnection *bus = NULL;
+
+	g_return_val_if_fail (GALEON_IS_DBUS (dbus), NULL);
+
+	if (kind == GALEON_DBUS_SYSTEM)
+	{
+		/* We connect lazily to the system bus */
+		if (priv->system_bus == NULL)
+		{
+			galeon_dbus_connect_to_system_bus (dbus, NULL);
+		}
+
+		bus = priv->system_bus;
+	}
+	else if (kind == GALEON_DBUS_SESSION)
+	{
+		if (priv->session_bus == NULL)
+		{
+			galeon_dbus_connect_to_session_bus (dbus, NULL);
+		}
+
+		bus = priv->session_bus;
+	}
+	else
+	{
+		g_assert_not_reached ();
+	}
+
+	return bus;
+}
+
+DBusGProxy *
+galeon_dbus_get_proxy (GaleonDbus *dbus,
+		     GaleonDbusBus kind)
+{
+	DBusGConnection *bus = NULL;
+
+	g_return_val_if_fail (GALEON_IS_DBUS (dbus), NULL);
+	
+	bus = galeon_dbus_get_bus (dbus, kind);
+
+	if (bus == NULL)
+	{
+		g_warning ("Unable to get proxy for the %s bus.\n",
+			   kind == GALEON_DBUS_SESSION ? "session" : "system");
+		return NULL;
+	}
+
+	return dbus_g_proxy_new_for_name (bus,
+					  DBUS_GALEON_SERVICE,
+					  DBUS_GALEON_PATH,
+					  DBUS_GALEON_INTERFACE);
+}
+
+/* private API */
+
+gboolean
+_galeon_dbus_startup (gboolean connect_and_register_name,
+		      GError **error)
+{
+	g_assert (galeon_dbus_instance == NULL);
+
+	galeon_dbus_error_quark = g_quark_from_static_string ("galeon-dbus-error");
+		
+	galeon_dbus_instance = g_object_new (GALEON_TYPE_DBUS,
+					     "register-name", connect_and_register_name,
+					     NULL);
+
+	if (!connect_and_register_name) return TRUE;
+
+	/* We only connect to the session bus on startup*/
+	return galeon_dbus_connect_to_session_bus (galeon_dbus_instance, error);
+}
+
+void
+_galeon_dbus_release (void)
+{
+	g_assert (galeon_dbus_instance != NULL);
+
+	g_object_unref (galeon_dbus_instance);
+	galeon_dbus_instance = NULL;
+}
+
+gboolean
+_galeon_dbus_is_name_owner (void)
+{
+	g_assert (galeon_dbus_instance != NULL);
+
+	return galeon_dbus_instance->priv->is_session_service_owner;
+}
diff --git a/src/galeon-dbus.h b/src/galeon-dbus.h
new file mode 100644
index 0000000..95d9cfd
--- /dev/null
+++ b/src/galeon-dbus.h
@@ -0,0 +1,91 @@
+/*
+ *  Copyright © 2004 Jean-François rameau
+ *
+ *  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 2, 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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GALEON_DBUS_H
+#define GALEON_DBUS_H
+
+#include <glib-object.h>
+
+/* Yes, we know that DBUS API isn't stable yet */
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+G_BEGIN_DECLS
+
+#define GALEON_TYPE_DBUS	 (galeon_dbus_get_type ())
+#define GALEON_DBUS(o)		 (G_TYPE_CHECK_INSTANCE_CAST ((o), GALEON_TYPE_DBUS, GaleonDbus))
+#define GALEON_DBUS_CLASS(k)	 (G_TYPE_CHECK_CLASS_CAST((k), GALEON_TYPE_DBUS, GaleonDbusClass))
+#define GALEON_IS_DBUS(o)	 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GALEON_TYPE_DBUS))
+#define GALEON_IS_DBUS_CLASS(k)	 (G_TYPE_CHECK_CLASS_TYPE ((k), GALEON_TYPE_DBUS))
+#define GALEON_DBUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GALEON_TYPE_DBUS, GaleonDbusClass))
+
+extern GQuark galeon_dbus_error_quark;
+#define GALEON_DBUS_ERROR_QUARK	(galeon_dbus_error_quark)
+
+typedef struct _GaleonDbus	GaleonDbus;
+typedef struct _GaleonDbusPrivate	GaleonDbusPrivate;
+typedef struct _GaleonDbusClass	GaleonDbusClass;
+
+typedef enum
+{
+	GALEON_DBUS_SESSION,
+	GALEON_DBUS_SYSTEM
+} GaleonDbusBus;
+
+struct _GaleonDbus
+{
+	GObject parent;
+
+	/*< private >*/
+	GaleonDbusPrivate *priv;
+};
+
+struct _GaleonDbusClass
+{
+	GObjectClass parent_class;
+
+	/* Signals */
+	void (* connected)	(GaleonDbus *dbus,
+				 GaleonDbusBus kind);
+	void (* disconnected)	(GaleonDbus *dbus,
+				 GaleonDbusBus kind);
+};
+
+GType		 galeon_dbus_get_type	 (void);
+
+GaleonDbus      *galeon_dbus_get_default (void);
+
+DBusGConnection *galeon_dbus_get_bus	 (GaleonDbus *dbus,
+					  GaleonDbusBus kind);
+
+DBusGProxy	*galeon_dbus_get_proxy	 (GaleonDbus *dbus,
+					  GaleonDbusBus kind);
+
+/* private */
+gboolean         _galeon_dbus_startup    (gboolean claim_name,
+					  GError **error);
+
+void	         _galeon_dbus_release	 (void);
+
+gboolean         _galeon_dbus_is_name_owner	(void);
+
+G_END_DECLS
+
+#endif /* !GALEON_DBUS_H */
diff --git a/src/galeon-main.c b/src/galeon-main.c
index f4ff922..ce71147 100644
--- a/src/galeon-main.c
+++ b/src/galeon-main.c
@@ -24,19 +24,19 @@
 #undef GNOME_DISABLE_DEPRECATED
 
 #include "galeon-shell.h"
-#include "galeon-automation.h"
 #include "galeon-window.h"
+#include "galeon-dbus.h"
+#include "galeon-dbus-client-bindings.h"
 #include "gul-state.h"
 #include "galeon-debug.h"
 #include "gul-x11.h"
 #include "hig-alert.h"
-#include "GaleonAutomation.h"
 
-#include <libbonoboui.h>
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-ui-init.h>
 #include <libgnomeui/gnome-app-helper.h>
 #include <libgnomevfs/gnome-vfs-init.h>
+#include <glib/gi18n.h>
 #include <gtk/gtkwindow.h>
 #include <gdk/gdkx.h>
 #include <string.h>
@@ -44,15 +44,10 @@
 # include <locale.h>
 #endif
 
-#define GALEON_FACTORY_OAFIID "OAFIID:GNOME_Galeon_Automation_Factory"
-
-static gint
-galeon_main_translate_url_arguments (poptContext context, gchar ***urls);
 static void
-galeon_main_start (guint32 user_time);
+galeon_main_start (DBusGProxy *proxy, guint32 user_time);
 
 /* FIXME */
-CORBA_Environment corba_env;			/* Global for downloader	*/
 static gboolean open_in_existing      = FALSE;  /* load in existing window?     */
 static gboolean open_in_new_tab       = FALSE;  /* force open in a new tab?     */
 static gboolean noraise               = FALSE;  /* no raise                     */
@@ -65,52 +60,51 @@ static gboolean close_option          = FALSE;  /* --close
 static gboolean quit_option           = FALSE;  /* --quit                       */
 static gboolean galeon_server_mode    = FALSE;
 
-static gint n_urls; 
-static gchar **url;
+static gchar **arguments              = NULL;
 
 /* command line argument parsing structure */
-static struct poptOption popt_options[] =
+static const GOptionEntry option_entries[] =
 {
-	{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, &bonobo_activation_popt_options, 0, NULL,
-	  NULL },
-	{ "new-tab", 'n', POPT_ARG_NONE, &open_in_new_tab, 0,
+	{ "new-tab", 'n', 0, G_OPTION_ARG_NONE, &open_in_new_tab,
 	  N_("Open a new tab in an existing Galeon window"),
 	  NULL },
-	{ "new-window", 'w', POPT_ARG_NONE, &open_in_new_window, 0,
+	{ "new-window", 'w', 0, G_OPTION_ARG_NONE, &open_in_new_window,
 	  N_("Open a new window in an existing Galeon process"),
 	  NULL },
-	{ "noraise", '\0', POPT_ARG_NONE, &noraise, 0,
+	{ "noraise", '\0', 0, G_OPTION_ARG_NONE, &noraise,
 	  N_("Do not raise the window when opening a page in an existing Galeon process"),
 	  NULL },
-	{ "fullscreen", 'f', POPT_ARG_NONE, &open_fullscreen, 0,
+	{ "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &open_fullscreen,
 	  N_("Run Galeon in full screen mode"),
 	  NULL },
-	{ "existing", 'x', POPT_ARG_NONE, &open_in_existing, 0,
+	{ "existing", 'x', 0, G_OPTION_ARG_NONE, &open_in_existing,
 	  N_("Attempt to load URL in existing Galeon window"),
 	  NULL },
-	{ "load-session", 'l', POPT_ARG_STRING, &session_filename, 0,
+	{ "load-session", 'l', 0, G_OPTION_ARG_STRING, &session_filename,
 	  N_("Load the given session file"),
 	  N_("FILE") },
-	{ "server", 's', POPT_ARG_NONE, &galeon_server_mode, 0,
+	{ "server", 's', 0, G_OPTION_ARG_NONE, &galeon_server_mode,
 	  N_("Don't open any windows; instead act as a server "
 	     "for quick startup of new Galeon instances"),
 	  NULL },		  
-	{ "add-bookmark", 't', POPT_ARG_STRING, &bookmark_url,
-	  0, N_("Add a bookmark (don't open any window)"), 
+	{ "add-bookmark", 't', 0, G_OPTION_ARG_STRING, &bookmark_url,
+	  N_("Add a bookmark (don't open any window)"),
 	  N_("URL")},
-	{ "geometry", 'g', POPT_ARG_STRING, &geometry_string,
-	  0, N_("Create the initial window with the given geometry, "
-		"see X(1) for the GEOMETRY format"),
+	{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry_string,
+          N_("Create the initial window with the given geometry, "
+	     "see X(1) for the GEOMETRY format"),
 	  N_("GEOMETRY")},
-	{ "close", 'c', POPT_ARG_NONE, &close_option, 0,
+	{ "close", 'c', 0, G_OPTION_ARG_NONE, &close_option,
 	  N_("Close all Galeon windows"),
 	  NULL },
-	{ "quit", 'q', POPT_ARG_NONE, &quit_option, 0,
+	{ "quit", 'q', 0, G_OPTION_ARG_NONE, &quit_option,
 	  N_("Same as --close, but exits server mode too"),
 	  NULL },
+        { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &arguments, "",
+          N_("URL ...") },
 
 	/* terminator, must be last */
-	{ NULL, 0, 0, NULL, 0, NULL, NULL }
+	{ NULL }
 };
 
 static void
@@ -190,13 +184,116 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
 	return event.xproperty.time;
 }
 
+static void
+shell_weak_notify (gpointer data,
+                   GObject *zombie)
+{
+        if (gtk_main_level ())
+        {
+                gtk_main_quit ();
+        }
+}
+
+static void
+unref_proxy_reply_cb (DBusGProxy *proxy,
+		      GError *error,
+		      gpointer user_data)
+{
+	if (error != NULL)
+	{
+		g_warning ("An error occurred while calling remote method: %s", error->message);
+		g_error_free (error);
+	}
+
+	g_object_unref (proxy);
+
+	if (gtk_main_level ())
+	{
+		gtk_main_quit ();
+	}
+}
+
+static gboolean
+open_urls (DBusGProxy *proxy,
+	   guint32 user_time,
+	   GError **error)
+{
+	static const char *empty_arguments[] = { "", NULL };
+	GString *options;
+	char **uris;
+
+	options = g_string_sized_new (64);
+
+	if (open_in_new_window)
+	{
+		g_string_append (options, "new-window,");
+	}
+	if (open_in_new_tab)
+	{
+		g_string_append (options, "new-tab,");
+	}
+        if (noraise)
+        {
+		g_string_append (options, "noraise,");
+        }
+        if (open_fullscreen)
+        {
+		g_string_append (options, "fullscreen,");
+        }
+
+	if (arguments == NULL)
+	{
+		uris = (char **) empty_arguments;
+	}
+	else
+	{
+		uris = (char **) arguments;
+	}
+
+	org_gnome_Galeon_load_ur_ilist_async
+		(proxy, (const char **) uris, options->str, user_time,
+		 unref_proxy_reply_cb, NULL);
+
+	if (arguments != NULL)
+	{
+		g_strfreev (arguments);
+		arguments = NULL;
+	}
+
+	g_string_free (options, TRUE);
+
+	return TRUE;
+}
+
+static void
+show_error_message (GError **error)
+{
+        GtkWidget *dialog;
+
+        /* FIXME better texts!!! */
+        dialog = gtk_message_dialog_new (NULL,
+                                         GTK_DIALOG_MODAL,
+                                         GTK_MESSAGE_ERROR,
+                                         GTK_BUTTONS_CLOSE,
+                                         _("Could not start Galeon Browser"));
+        gtk_message_dialog_format_secondary_text
+                (GTK_MESSAGE_DIALOG (dialog),
+                 _("Startup failed because of the following error:\n%s"),
+                 (*error)->message);
+
+        g_clear_error (error);
+
+        gtk_dialog_run (GTK_DIALOG (dialog));
+}
+
 int
 main (int argc, char *argv[])
 {
-	poptContext context;
-        GValue context_as_value = { 0 };
-	GnomeProgram *program;
-	CORBA_Object factory;
+        GnomeProgram *program;
+        GOptionContext *option_context;
+        GOptionGroup *option_group;
+        GError *error = NULL;
+        DBusGProxy *proxy;
 	guint32 user_time;
 
 #ifdef ENABLE_NLS
@@ -208,9 +305,26 @@ main (int argc, char *argv[])
 	/* get this early, since gdk will unset the env var */
 	user_time = gul_x11_get_startup_id ();
 
+        g_type_init ();
+        g_thread_init (NULL);
+
+	dbus_g_thread_init ();
+
+        option_context = g_option_context_new ("");
+        option_group = g_option_group_new ("galeon",
+                                           N_("Galeon Web Browser"),
+                                           N_("Galeon Web Browser options"),
+                                           NULL, NULL);
+
+        g_option_group_set_translation_domain (option_group, GETTEXT_PACKAGE);
+
+        g_option_group_add_entries (option_group, option_entries);
+
+        g_option_context_set_main_group (option_context, option_group);
+
 	program = gnome_program_init (PACKAGE, VERSION,
                                       LIBGNOMEUI_MODULE, argc, argv,
-                                      GNOME_PARAM_POPT_TABLE, popt_options,
+                                      GNOME_PARAM_GOPTION_CONTEXT, option_context,
                                       GNOME_PARAM_HUMAN_READABLE_NAME, _("Galeon"),
 				      GNOME_PARAM_APP_DATADIR, DATADIR,
                                       NULL);
@@ -229,26 +343,34 @@ main (int argc, char *argv[])
 	 */
 	g_set_application_name (_("Galeon"));
 
-        g_object_get_property (G_OBJECT (program),
-                               GNOME_PARAM_POPT_CONTEXT,
-                               g_value_init (&context_as_value, G_TYPE_POINTER));
+        if (! _galeon_dbus_startup (TRUE, &error))
+	{
+		_galeon_dbus_release ();
 
-        context = g_value_get_pointer (&context_as_value);
+		show_error_message (&error);
 
-	/* load arguments that aren't regular options (urls to load) */
-        n_urls = galeon_main_translate_url_arguments (context, &url);
+		exit (1);
+	}
+
+        /* Create DBUS proxy */
+        proxy = galeon_dbus_get_proxy (galeon_dbus_get_default (), GALEON_DBUS_SESSION);
+        if (proxy == NULL)
+        {
+                error = g_error_new (1, // STARTUP_ERROR_QUARK,
+                                     0,
+                                     "Unable to get DBus proxy; aborting activation."); /* FIXME i18n */
 
-	g_value_unset (&context_as_value);
+                _galeon_dbus_release ();
 
-	factory = bonobo_activation_activate_from_id 
-		(GALEON_FACTORY_OAFIID,
-		 Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, 
-		 NULL, NULL);
+                show_error_message (&error);
 
-	if (factory != NULL)
+                exit (1);
+        }
+
+        if (! _galeon_dbus_is_name_owner ())
 	{
 		/* Connect to existing instance */
-		galeon_main_start (user_time);
+		galeon_main_start (proxy, user_time);
 		gdk_notify_startup_complete ();
 	}
 	else
@@ -264,18 +386,17 @@ main (int argc, char *argv[])
 		galeon_shell_new ();
 		
 		/* Gdk will handle the user time itself */
-		galeon_main_start (0u);
+		galeon_main_start (proxy, 0u);
 
 		/* Flush any pending GTK events, this works around crashes when
 		 * it takes a long time to startup. */
 		while (gtk_events_pending())
 			gtk_main_iteration();
-		
-		galeon_automation_complete_initialization ();
-		
+
+                g_object_weak_ref (G_OBJECT (galeon_shell), shell_weak_notify, NULL);
 		g_idle_add (unref_when_idle, galeon_shell);
-		
-		bonobo_main ();
+
+                gtk_main ();
 		
 		gul_state_shutdown ();
 
@@ -284,165 +405,72 @@ main (int argc, char *argv[])
 		gnome_vfs_shutdown ();
 	} 
 
+        _galeon_dbus_release ();
+
 	return 0;
 }
 
 static void
-galeon_main_start (guint32 user_time)
+galeon_main_start (DBusGProxy *proxy, guint32 user_time)
 {
-	GNOME_GaleonAutomation gaserver;
-	int i;
-
-	CORBA_exception_init (&corba_env);
-	
-	gaserver = bonobo_activation_activate_from_id ("OAFIID:GNOME_Galeon_Automation",
-						       0, NULL, &corba_env);
-	
-	if (corba_env._major != CORBA_NO_EXCEPTION)
-	{
-		g_warning ("Error: unable to initialize corba: %s\n", 
-			   CORBA_exception_id (&corba_env));
-	} 
+        GError   *error    = NULL;
+        gboolean  success;
 
-	if (gaserver == NULL)
-	{
-		/* At this point the galeon_shell will have initialized the
-		 * AutomationFactory, that obviously worked, so the .server file
-		 * exists, therefore this was probably because a previous instance
-		 * locked up */
-
-		GtkWidget *dialog;
-		dialog = hig_alert_new (NULL,
-					GTK_DIALOG_MODAL,
-					HIG_ALERT_ERROR,
-					_("Galeon failed to start."),
-					_("The existing Galeon instance is not responding. "
-					  "Terminating the <tt>\"galeon\"</tt> processes "
-					  "may fix the problem."),
-					GTK_STOCK_OK,
-					GTK_RESPONSE_OK,
-					NULL);
-		gtk_dialog_run (GTK_DIALOG (dialog));
-		gtk_widget_destroy (dialog);
-		exit(1);
-	}
 	/* Server mode */
-	if (galeon_server_mode && !close_option)
+	if (galeon_server_mode && ! close_option)
 	{
-		GNOME_GaleonAutomation_setServerMode (gaserver, TRUE, &corba_env);
+                GaleonShell *shell = galeon_shell_get_default ();
+
+                galeon_shell_set_server_mode (shell, TRUE);
 	}
 
 	/* load the session if requested */
 	if (session_filename)
 	{
-		GNOME_GaleonAutomation_loadSessionWithStartupId
-			(gaserver, session_filename, user_time, &corba_env);
+                org_gnome_Galeon_load_session_async (proxy,
+                                                     session_filename,
+                                                     user_time,
+                                                     unref_proxy_reply_cb,
+                                                     NULL);
 	}
 	/* if found and we're given a bookmark to add... */
 	else if (bookmark_url != NULL)
 	{
-		GNOME_GaleonAutomation_addBookmark 
-			(gaserver, bookmark_url, &corba_env);
-	}
-	else if (close_option || quit_option)
-	{
-		GNOME_GaleonAutomation_quit 
-			(gaserver, quit_option, &corba_env);
-	}
-	/* provided with urls? */
-	else if (n_urls == 0 && 
-		 !galeon_server_mode)
-	{
-		/* no, open a default window */
-		GNOME_GaleonAutomation_loadurlWithStartupId 
-			(gaserver, "",
-			 geometry_string ?
-			 geometry_string : "",
-			 open_fullscreen,
-			 open_in_existing,
-			 open_in_new_window,
-			 open_in_new_tab,
-			 !noraise,
-			 user_time,
-			 &corba_env);
-	}
-	else
-	{
-		/* open all of the urls */
-		for (i = 0; i < n_urls; i++)
-		{
-			GNOME_GaleonAutomation_loadurlWithStartupId
-				(gaserver, url[i],
-				 geometry_string ?
-				 geometry_string : "",
-				 open_fullscreen,
-				 open_in_existing,
-				 open_in_new_window,
-				 open_in_new_tab,
-				 !noraise,
-				 user_time,
-				 &corba_env);
-		}
-	}
+                GbBookmarkSet *set;
+                GaleonShell   *shell;
+                GbSite        *bookmark;
 
-	if (gaserver)
-	{
-		bonobo_object_release_unref (gaserver, &corba_env);
-	}
-
-	CORBA_exception_free (&corba_env);
-}
+                shell = galeon_shell_get_default ();
 
-/**
- * translate_url_arguments: gather URL arguments and expand them fully
- * with realpath if they're filenames
- */
-static gint
-galeon_main_translate_url_arguments (poptContext context, gchar ***urls)
-{
-        gchar buffer[PATH_MAX];
-        gchar **args;
-        gint i, n;
+                set = galeon_shell_get_bookmark_set (shell);
+                g_return_if_fail (set);
 
-        /* any context remaining? */
-        if (context == NULL)
-        {
-                *urls = NULL;
-                return 0;
-        }
-
-        /* get the args and check */
-        args = (gchar **) poptGetArgs (context);
-        if (args == NULL)
-        {
-                poptFreeContext (context);
-                *urls = NULL;
-                return 0;
-        }
+                bookmark = gb_site_new (set, NULL, bookmark_url);
+                gb_bookmark_set_add_default (set, GB_BOOKMARK (bookmark));
+	}
+	else if (close_option || quit_option)
+	{
+                success = org_gnome_Galeon_quit (proxy, quit_option, &error);
+                if (! success) {
+                        _galeon_dbus_release ();
 
-        /* count args */
-        for (n = 0; args[n] != NULL; n++)
-                /* nothing */;
+                        show_error_message (&error);
 
-        /* allocate pointer array */
-        *urls = g_new0 (gchar *, n + 1);
-        
-        /* translate each one */
-        for (i = 0; i < n; i++)
-        {
-                /* try to expand as files */
-                if (realpath (args[i], buffer) != NULL)
-                {
-                        (*urls)[i] = g_strconcat ("file://", buffer, NULL);
+                        exit (1);
                 }
-                else
+	}
+        else if (arguments || ! galeon_server_mode) {
+         	success = open_urls (proxy, user_time, &error);
+                if (! success)
                 {
-                        (*urls)[i] = g_strdup (args[i]);
+                        _galeon_dbus_release ();
+
+                        show_error_message (&error);
+
+                        exit (1);
                 }
         }
-        poptFreeContext (context);
-        (*urls)[i] = NULL;
 
-        /* return the number of urls */
-        return n;
+	/* FIXME why? */
+        dbus_g_connection_flush (galeon_dbus_get_bus (galeon_dbus_get_default (), GALEON_DBUS_SESSION));
 }
diff --git a/src/session.c b/src/galeon-session.c
similarity index 78%
rename from src/session.c
rename to src/galeon-session.c
index 071c49a..af8cab1 100644
--- a/src/session.c
+++ b/src/galeon-session.c
@@ -16,7 +16,7 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include "session.h"
+#include "galeon-session.h"
 #include "galeon-shell.h"
 #include "galeon-dialog.h"
 #include "galeon-tab.h"
@@ -65,18 +65,31 @@ static void session_finalize (GObject *object);
 static void session_dispose (GObject *object);
 static void session_create_bookmarks (Session *session, const char *filename);
 
+static gboolean session_command_dispatch (Session *session);
+
 static GObjectClass *parent_class = NULL;
 
 #define SESSION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
 				       TYPE_SESSION, SessionPrivate))
 
 
+typedef struct
+{
+        GaleonSessionCommand command;
+        GValue *arg;
+        char **args;
+        guint32 user_time;
+} SessionCommand;
+
 struct SessionPrivate
 {
 	GaleonDialog *crash_dialog;
 	GList *windows;
 	gboolean dont_remove_crashed;
 	gboolean session_saved;
+
+        GQueue *queue;
+        guint queue_idle_id;
 };
 
 enum
@@ -361,8 +374,12 @@ static void
 gnome_session_init (Session *session)
 {
 	GnomeClient *client;
+        SessionPrivate *priv;
 		
 	client = gnome_master_client ();
+
+        priv = session->priv = SESSION_GET_PRIVATE (session);
+        priv->queue = g_queue_new ();
 	
 	g_signal_connect (G_OBJECT (client), 
 			  "save_yourself",
@@ -729,7 +746,7 @@ create_new_window (xmlNodePtr child,
  * files (used when galeon crashed)
  */
 
-static void 
+static void
 bookmark_from_tab (const char *url, const char *title, GbFolder *folder)
 {
 	GbSite *new_site;
@@ -745,7 +762,7 @@ bookmark_from_tab (const char *url, const char *title, GbFolder *folder)
 
 static void
 bookmarks_from_window (xmlNodePtr child,
-		       const int x, const int y, 
+		       const int x, const int y,
 		       const int width, const int height,
 		       const char *role,
 		       GbFolder *folder)
@@ -872,3 +889,232 @@ session_remove_window (Session *session,
 	}
 }
 
+static int
+session_command_find (const SessionCommand *cmd,
+                      gpointer cmdptr)
+{
+        GaleonSessionCommand command = GPOINTER_TO_INT (cmdptr);
+
+        return command != cmd->command;
+}
+
+static void
+session_command_queue_next (Session *session)
+{
+        SessionPrivate *priv = session->priv;
+
+        if (!g_queue_is_empty (priv->queue) &&
+            priv->crash_dialog == NULL &&
+            priv->queue_idle_id == 0)
+        {
+                priv->queue_idle_id =
+                        g_idle_add ((GSourceFunc) session_command_dispatch,
+                                    session);
+        }
+}
+
+/**
+ * galeon_session_queue_command:
+ * @session: a #GaleonSession
+ **/
+void
+galeon_session_queue_command (Session *session,
+			      GaleonSessionCommand command,
+			      GValue *arg,
+			      char **args,
+			      guint32 user_time,
+			      gboolean priority)
+{
+	SessionPrivate *priv;
+	GList *element;
+	SessionCommand *cmd;
+
+	g_return_if_fail (IS_SESSION (session));
+	g_return_if_fail (command != GALEON_SESSION_CMD_OPEN_URIS || args != NULL);
+
+	priv = session->priv;
+
+	/* First look if the same command is already queued */
+	if (command == GALEON_SESSION_CMD_LOAD_SESSION)
+	{
+		element = g_queue_find_custom (priv->queue,
+					       GINT_TO_POINTER (command),
+					       (GCompareFunc) session_command_find);
+		if (element != NULL)
+		{
+			cmd = (SessionCommand *) element->data;
+
+			if (command == GALEON_SESSION_CMD_LOAD_SESSION &&
+			    strcmp (g_value_get_string (cmd->arg), g_value_get_string (arg)) == 0)
+			{
+				cmd->user_time = user_time;
+				g_queue_remove (priv->queue, cmd);
+				g_queue_push_tail (priv->queue, cmd);
+
+				return;
+			}
+		}
+	}
+
+	/* FIXME: use g_slice_new */
+	cmd = g_new0 (SessionCommand, 1);
+	cmd->command = command;
+
+	cmd->arg = g_new0 (GValue, 1);
+        g_value_init (cmd->arg, G_VALUE_TYPE (arg));
+        g_value_copy (arg, cmd->arg);
+
+	cmd->args = args ? g_strdupv (args) : NULL;
+	cmd->user_time = user_time;
+	/* This ref is released in session_command_free */
+	g_object_ref (galeon_shell_get_default ());
+
+	if (priority)
+	{
+		g_queue_push_head (priv->queue, cmd);
+	}
+	else
+	{
+		g_queue_push_tail (priv->queue, cmd);
+	}
+
+	session_command_queue_next (session);
+
+	if (priv->crash_dialog != NULL)
+	{
+		gtk_window_present_with_time (GTK_WINDOW (priv->crash_dialog),
+					      user_time);
+	}
+}
+
+static void
+session_command_free (SessionCommand *cmd)
+{
+	g_assert (cmd != NULL);
+
+        g_value_unset (cmd->arg);
+	g_free (cmd->arg);
+	if (cmd->args)
+	{
+		g_strfreev (cmd->args);
+	}
+
+	g_free (cmd);
+
+	g_object_unref (galeon_shell_get_default ());
+}
+
+static void
+session_command_open_uris (Session *session,
+			   char **uris,
+			   const char *options,
+			   guint32 user_time)
+{
+	GaleonShell *shell;
+	GaleonWindow *window;
+	GaleonTab *tab;
+	GaleonNewTabFlags flags = 0;
+	guint i;
+
+	shell = galeon_shell_get_default ();
+
+	g_object_ref (shell);
+
+	window = galeon_shell_get_active_window (shell);
+
+	if (options != NULL && strstr (options, "new-window") != NULL)
+	{
+		window = NULL;
+		flags |= GALEON_NEW_TAB_IN_NEW_WINDOW;
+	}
+	else if (options != NULL && strstr (options, "new-tab") != NULL)
+	{
+		flags |= GALEON_NEW_TAB_IN_EXISTING_WINDOW |
+			 GALEON_NEW_TAB_JUMP;
+	}
+
+        if (options != NULL && strstr (options, "noraise") == NULL)
+        {
+                flags |= GALEON_NEW_TAB_RAISE_WINDOW;
+        }
+        if (options != NULL && strstr (options, "fullscreen") != NULL)
+        {
+                flags |= GALEON_NEW_TAB_FULLSCREEN;
+        }
+
+	for (i = 0; uris[i] != NULL; ++i)
+	{
+		const char *url = uris[i];
+		GaleonNewTabFlags page_flags;
+
+		if (url[0] == '\0')
+		{
+			page_flags = GALEON_NEW_TAB_HOMEPAGE;
+		}
+		else
+		{
+			page_flags = GALEON_NEW_TAB_JUMP;
+		}
+
+		tab = galeon_shell_new_tab_full (shell, window,
+						 NULL /* parent tab */,
+						 url,
+						 flags | page_flags,
+						 user_time);
+
+		window = GALEON_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab)));
+	}
+
+	g_object_unref (shell);
+}
+
+static gboolean
+session_command_dispatch (Session *session)
+{
+	SessionPrivate *priv = session->priv;
+	SessionCommand *cmd;
+	gboolean run_again = TRUE;
+
+	cmd = g_queue_pop_head (priv->queue);
+	g_assert (cmd != NULL);
+
+	switch (cmd->command)
+	{
+                case GALEON_SESSION_CMD_OPEN_URIS:
+			session_command_open_uris (session,
+                                                   cmd->args,
+                                                   g_value_get_string (cmd->arg),
+                                                   cmd->user_time);
+			break;
+		case GALEON_SESSION_CMD_LOAD_SESSION:
+			session_load (session,
+                                      g_value_get_string (cmd->arg),
+                                      cmd->user_time);
+			break;
+                case GALEON_SESSION_QUIT:
+                        session_close (session);
+
+                        /* exit server */
+                        if (g_value_get_boolean (cmd->arg))
+                        {
+                                g_object_unref (galeon_shell_get_default ());
+                        }
+                        break;
+		default:
+			g_assert_not_reached ();
+			break;
+	}
+
+	/* Look if there's anything else to dispatch */
+	if (g_queue_is_empty (priv->queue) ||
+	    priv->crash_dialog!= NULL)
+	{
+		priv->queue_idle_id = 0;
+		run_again = FALSE;
+	}
+
+	/* This unrefs the shell! */
+	session_command_free (cmd);
+
+	return run_again;
+}
diff --git a/src/session.h b/src/galeon-session.h
similarity index 88%
rename from src/session.h
rename to src/galeon-session.h
index aa69cee..3e3f0ee 100644
--- a/src/session.h
+++ b/src/galeon-session.h
@@ -44,9 +44,15 @@ typedef struct SessionPrivate SessionPrivate;
 typedef enum {
    SESSION_OK,
    SESSION_RESUMED,
-   SESSION_ABORT
+   SESSION_ABORT,
 } SessionResumeType;
 
+typedef enum {
+   GALEON_SESSION_CMD_LOAD_SESSION,
+   GALEON_SESSION_CMD_OPEN_URIS,
+   GALEON_SESSION_QUIT,
+} GaleonSessionCommand;
+
 struct Session
 {
         GObject parent;
@@ -86,6 +92,12 @@ void          session_add_window      	(Session *session,
 
 void          session_remove_window     (Session *session,
 					 GaleonWindow *window);
+void 	      galeon_session_queue_command	(Session *session,
+					 GaleonSessionCommand op,
+					 GValue *arg,
+					 char **args,
+					 guint32 user_time,
+					 gboolean priority);
 
 G_END_DECLS
 
diff --git a/src/galeon-shell.c b/src/galeon-shell.c
index b1e8321..ed0a7fb 100644
--- a/src/galeon-shell.c
+++ b/src/galeon-shell.c
@@ -30,7 +30,6 @@
 #include "galeon-bookmarks-icon-provider.h"
 #include "gul-filesystem-autocompletion.h"
 #include "galeon-window.h"
-#include "galeon-automation.h"
 #include "hig-alert.h"
 #include "migrate.h"
 #include "galeon-debug.h"
@@ -61,7 +60,6 @@ struct GaleonShellPrivate
 	GaleonWindow *active_window;
 	EggToolbarsModel *toolbars_model;
 	gboolean server_mode;
-	BonoboGenericFactory *automation_factory;
 	GaleonSidebars * sidebars;
 };
 
@@ -182,31 +180,6 @@ galeon_shell_init (GaleonShell *gs)
 	gs->priv->session     = NULL;
 	gs->priv->server_mode = FALSE;
 
-	gs->priv->automation_factory = galeon_automation_factory_new ();
-	if (gs->priv->automation_factory == NULL)
-	{
-		GtkWidget *dialog;
-		char * text;
-
-		dialog = hig_alert_new (NULL,
-					GTK_DIALOG_MODAL,
-					HIG_ALERT_ERROR,
-					_("Galeon failed to start."),
-					NULL,
-					GTK_STOCK_OK,
-					GTK_RESPONSE_OK,
-					NULL);
-		text = g_strdup_printf (_("Bonobo couldn't locate the file %s."),
-			                "<tt>\"GNOME_Galeon_Automation.server\"</tt>");
-		hig_alert_set_secondary_printf (HIG_ALERT (dialog), "%s\n\n%s", text,
-			      _("Usually this is an indication of an incomplete installation. "
-				"See the INSTALL document for more details."));
-		g_free (text);
-
-		gtk_dialog_run (GTK_DIALOG (dialog));
-		exit (1);
-	}
-
 	/* Check the gconf installation */
 	schema = gconf_client_get_schema (eel_gconf_client_get_global (),
 					  "/schemas" CONF_TABS_TABBED_EDGE, NULL);
@@ -332,16 +305,6 @@ galeon_shell_finalize (GObject *object)
         G_OBJECT_CLASS (parent_class)->finalize (object);
 
 	LOG ("Galeon shell finalized");
-
-	if (gs->priv->automation_factory)
-	{
-		bonobo_object_unref (gs->priv->automation_factory);
-	}
-	
-
-	bonobo_main_quit ();
-
-	LOG ("Bonobo quit done");
 }
 
 GaleonShell *
@@ -438,6 +401,19 @@ load_homepage (GaleonShell *gs,
 }
 
 /**
+ * galeon_shell_get_default:
+ *
+ * Retrieve the default #GaleonShell object
+ *
+ * ReturnValue: the default #GaleonShell
+ **/
+GaleonShell *
+galeon_shell_get_default (void)
+{
+        return galeon_shell;
+}
+
+/**
  * galeon_shell_set_active_window:
  * @gs: a #GaleonShell
  * @window: the active #GaleonWindow
diff --git a/src/galeon-shell.h b/src/galeon-shell.h
index 750b88d..adef777 100644
--- a/src/galeon-shell.h
+++ b/src/galeon-shell.h
@@ -24,7 +24,7 @@
 #include "downloader-view.h"
 #include "galeon-embed-shell.h"
 #include "bookmarks.h"
-#include "session.h"
+#include "galeon-session.h"
 #include "galeon-favicon-cache.h"
 #include "egg-toolbars-model.h"
 #include "galeon-sidebars.h"
@@ -83,6 +83,8 @@ GType               galeon_shell_get_type            (void);
 
 GaleonShell        *galeon_shell_new                 (void);
 
+GaleonShell        *galeon_shell_get_default         (void);
+
 GaleonEmbedShell   *galeon_shell_get_embed_shell     (GaleonShell *gs);
 
 void		    galeon_shell_set_active_window   (GaleonShell *gs,
diff --git a/src/galeon-sidebars.c b/src/galeon-sidebars.c
index 44fe949..c15c664 100644
--- a/src/galeon-sidebars.c
+++ b/src/galeon-sidebars.c
@@ -24,7 +24,7 @@
 #include "galeon-window.h"
 #include "galeon-shell.h"
 #include "galeon-sidebar-embed.h"
-#include "session.h"
+#include "galeon-session.h"
 #include "gul-general.h"
 #include "galeon-config.h"
 #include "hig-alert.h"
diff --git a/src/galeon-window-menu.c b/src/galeon-window-menu.c
index 4d13614..a4757a8 100644
--- a/src/galeon-window-menu.c
+++ b/src/galeon-window-menu.c
@@ -28,7 +28,7 @@
 #include <gtk/gtkactiongroup.h>
 #include <gtk/gtkaction.h>
 
-#include "session.h"
+#include "galeon-session.h"
 #include "galeon-window.h"
 #include "galeon-shell.h"
 #include "galeon-window-menu.h"
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 80b3697..d7c5d1b 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -11,13 +11,7 @@ if MAINTAINER_MODE
 noinst_PROGRAMS=
 endif
 
-gtm_automation_idl_sources =	\
-	Gtm-common.c		\
-	Gtm-stubs.c		\
-	Gtm.h
-
 nodist_libutils_la_SOURCES = 			\
-	$(gtm_automation_idl_sources)		\
 	galeon-marshal.c			\
 	galeon-marshal.h
 
@@ -88,7 +82,7 @@ libutils_la_SOURCES = \
 	galeon-auto-bookmarks-source.h
 
 # FIXME: someone with better automake knowledge may de this better:
-BUILT_SOURCES=galeon-marshal.c galeon-marshal.h Gtm.h Gtm-common.c Gtm-stubs.c
+BUILT_SOURCES=galeon-marshal.c galeon-marshal.h
 
 CLEANFILES = $(BUILT_SOURCES)
 
@@ -98,10 +92,7 @@ galeon-marshal.c: galeon-marshal.list
 galeon-marshal.h: galeon-marshal.list
 	$(GLIB_GENMARSHAL) --prefix=galeon_marshal $(srcdir)/galeon-marshal.list --header > galeon-marshal.h
 
-Gtm-common.c Gtm-stubs.c Gtm.h: $(top_srcdir)/idl/Gtm.idl
-	$(ORBIT_IDL) --noskels $(top_srcdir)/idl/Gtm.idl 
-
-EXTRA_DIST = galeon-marshal.list $(top_srcdir)/idl/Gtm.idl
+EXTRA_DIST = galeon-marshal.list
 
 # Quiet compilation
 LIBTOOL = $(SHELL) $(top_builddir)/libtool $(LIBTOOL_ARG)
diff --git a/utils/galeon-marshal.list b/utils/galeon-marshal.list
index 98091c6..c258f25 100644
--- a/utils/galeon-marshal.list
+++ b/utils/galeon-marshal.list
@@ -9,6 +9,7 @@ VOID:OBJECT,INT,INT
 VOID:STRING,INT,INT
 VOID:STRING,INT
 VOID:STRING,STRING
+VOID:ENUM
 INT:STRING
 VOID:INT,INT
 VOID:INT,INT,INT
diff --git a/utils/gul-download.c b/utils/gul-download.c
index 3b01e40..fb842f4 100644
--- a/utils/gul-download.c
+++ b/utils/gul-download.c
@@ -24,7 +24,6 @@
 #include "gul-download.h"
 #include "gul-string.h"
 #include "prefs-strings.h"
-#include "Gtm.h"
 
 #include <string.h>
 
@@ -33,7 +32,6 @@
 #include <glib/gi18n.h>
 #include <libgnome/gnome-exec.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
-#include <bonobo-activation/bonobo-activation-activate.h>
 #include <gtk/gtk.h>
 
 static gboolean gul_download_gtm_add_url (const gchar *url, gchar *dir, 
@@ -310,48 +308,5 @@ static gboolean
 gul_download_gtm_add_url (const gchar *url, gchar *dir, gboolean disable_proxy,
 			gboolean disable_auto_dl)
 {
-	CORBA_Environment ev;
-	extern CORBA_Environment corba_env;
-	GTM_Download gtm_download_client;
-	gboolean result;
-
-	/* exception catching environment */
-	CORBA_exception_init (&ev);
-
-	result = FALSE;
-
-	ev = corba_env;
-	gtm_download_client =   
-		bonobo_activation_activate_from_id ("OAFIID:GNOME_GTM", 
-						    0, NULL, &ev);
-
-	if (gtm_download_client != NULL)
-	{
-		result = GTM_Download_add_url ( gtm_download_client, url, dir,
-						disable_proxy,
-						disable_auto_dl, &ev);
-		
-		if (ev._major != CORBA_NO_EXCEPTION)
-		{
-			g_warning ("Exception thrown: %s\n", 
-				   CORBA_exception_id (&ev));
-			CORBA_exception_free (&ev);
-		}
-	}
-	else
-	{
-		/* GtkWidget *dialog; */
-		gchar *text;
-
-		text = g_strdup_printf (_("Failed to communicate with GTM.\n\n"
-					  "Please check it is installed "
-					  "correctly. Download it from:\n"
-					  "\thttp://gtm.sourceforge.net";));
-		/* dialog = gnome_error_dialog (text); */
-		/* gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); */
-		g_warning("%s",text);
-		g_free (text);
-	}
-  
-	return result;
+	return TRUE;
 }



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