aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-main.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-24 05:35:18 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-24 05:35:18 +0800
commit3c094d65a71666e40b14cb8edc8bbb255b09b8cf (patch)
treeded1435b5ff1d320f37c834e883defa43ba5741e /src/ephy-main.c
parentb32d62815640aabd7e2b8f88ee8577ad02c7796f (diff)
downloadgsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.gz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.bz2
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.lz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.xz
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.tar.zst
gsoc2013-epiphany-3c094d65a71666e40b14cb8edc8bbb255b09b8cf.zip
Add a GError** to ephy_file_helpers_init and ephy_ensure_dir_exists, so we
2006-01-23 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/MozDownload.cpp: * lib/ephy-file-helpers.c: (ephy_file_helpers_init), (ephy_ensure_dir_exists): * lib/ephy-file-helpers.h: Add a GError** to ephy_file_helpers_init and ephy_ensure_dir_exists, so we can show the error to the user in main(). * src/ephy-dbus.c: (ephy_dbus_connect_to_session_bus_cb), (ephy_dbus_connect_to_system_bus_cb), (session_filter_func), (system_filter_func), (ephy_dbus_connect_to_system_bus), (ephy_dbus_connect_to_session_bus), (ephy_dbus_shutdown), (ephy_dbus_finalize), (ephy_dbus_get_type), (ephy_dbus_get_default), (ephy_dbus_get_bus), (ephy_dbus_get_proxy), (_ephy_dbus_startup), (_ephy_dbus_release), (_ephy_dbus_is_name_owner): * src/ephy-dbus.h: Refactored. Propagate errors to callers via GError**, and change lifecycle to the app lifetime. * src/ephy-lockdown.c: (ephy_lockdown_init), (ephy_lockdown_finalize): Move gconf notification add/remove for the lockdown key dirs here from main(). * src/ephy-shell.c: (ephy_shell_dispose), (_ephy_shell_create_instance): * src/ephy-shell.h: * src/epiphany.defs: Remove ephy_shell_startup and related stuff. * src/ephy-main.c: (handle_url), (handle_email), (shell_weak_notify), (dbus_g_proxy_finalized_cb), (save_yourself_cb), (die_cb), (gnome_session_init), (path_from_command_line_arg), (open_urls), (call_dbus_proxy), (show_error_message), (main): Move all startup code to main(), so we can show errors to the user instead of crashing when things go wrong. Part of bug #326807.
Diffstat (limited to 'src/ephy-main.c')
-rw-r--r--src/ephy-main.c628
1 files changed, 497 insertions, 131 deletions
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 9eeadfebd..88444dae0 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -20,8 +20,6 @@
#include "config.h"
-#undef GNOME_DISABLE_DEPRECATED
-
#include "ephy-shell.h"
#include "ephy-file-helpers.h"
#include "ephy-object-helpers.h"
@@ -29,54 +27,88 @@
#include "ephy-debug.h"
#include "ephy-stock-icons.h"
#include "eel-gconf-extensions.h"
+#include "ephy-dbus-client-bindings.h"
+#include "ephy-activation.h"
+#include "ephy-session.h"
+#include "ephy-shell.h"
+#include "ephy-debug.h"
-#include <libgnomeui/gnome-ui-init.h>
-#include <libgnomeui/gnome-app-helper.h>
+#include <libxml/xmlversion.h>
+
+#include <glib/gi18n.h>
+
+#include <gdk/gdkx.h>
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmessagedialog.h>
-#include <gdk/gdkx.h>
+
#include <libgnome/gnome-program.h>
-#include <glib/gi18n.h>
+#include <libgnomeui/gnome-client.h>
+
+/* libgnome < 2.13 compat */
+#ifndef GNOME_PARAM_GOPTION_CONTEXT
+#include <libgnomeui/gnome-ui-init.h>
+#endif
+
#include <libgnomevfs/gnome-vfs-init.h>
#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libxml/xmlversion.h>
+#include <libgnomeui/gnome-app-helper.h>
+
#include <errno.h>
#include <string.h>
-static gboolean open_in_existing = FALSE;
+static GQuark startup_error_quark = 0;
+#define STARTUP_ERROR_QUARK (startup_error_quark)
+
static gboolean open_in_new_tab = FALSE;
-static gboolean open_fullscreen = FALSE;
+static gboolean open_in_new_window = FALSE;
static gboolean open_as_bookmarks_editor = FALSE;
-static gboolean reload_plugins = FALSE;
+//static gboolean reload_plugins = FALSE;
static char *session_filename = NULL;
static char *bookmark_url = NULL;
static char *bookmarks_file = NULL;
+static char **remaining_arguments = NULL;
+
+static const GOptionEntry option_entries[] =
+{
+ { "new-tab", 'n', 0, G_OPTION_ARG_NONE, &open_in_new_tab,
+ N_("Open a new tab in an existing Epiphany window"), NULL },
+ { "new-window", 0, 0, G_OPTION_ARG_NONE, &open_in_new_window,
+ N_("Open a new tab in an existing Epiphany window"), NULL },
+ { "bookmarks-editor", 'b', 0, G_OPTION_ARG_NONE, &open_as_bookmarks_editor,
+ N_("Launch the bookmarks editor"), NULL },
+ { "import-bookmarks", '\0', 0, G_OPTION_ARG_FILENAME, &bookmarks_file,
+ N_("Import bookmarks from the given file"), N_("FILE") },
+ { "load-session", 'l', 0, G_OPTION_ARG_FILENAME, &session_filename,
+ N_("Load the given session file"), N_("FILE") },
+ { "add-bookmark", 't', 0, G_OPTION_ARG_STRING, &bookmark_url,
+ N_("Add a bookmark"), N_("URL") },
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_arguments,
+ "", "" },
+ { NULL }
+};
-static struct poptOption popt_options[] =
+#ifndef GNOME_PARAM_GOPTION_CONTEXT
+/* libgnome < 2.13 compat */
+static char *sm_client_id = NULL;
+static char *sm_config_prefix = NULL;
+static gboolean sm_disable = FALSE;
+static gboolean disable_crash_dialog = FALSE;
+
+static const GOptionEntry libgnome_option_entries[] =
{
- { "new-tab", 'n', POPT_ARG_NONE, &open_in_new_tab, 0,
- N_("Open a new tab in an existing window"),
- NULL },
- { "fullscreen", 'f', POPT_ARG_NONE, &open_fullscreen, 0,
- N_("Run in full screen mode"),
- NULL },
- { "load-session", 'l', POPT_ARG_STRING, &session_filename, 0,
- N_("Load the given session file"),
- N_("FILE") },
- { "add-bookmark", 't', POPT_ARG_STRING, &bookmark_url,
- 0, N_("Add a bookmark (don't open any window)"),
- N_("URL")},
- { "import-bookmarks", '\0', POPT_ARG_STRING, &bookmarks_file,
- 0, N_("Import bookmarks from the given file"),
- N_("FILE") },
- { "bookmarks-editor", 'b', POPT_ARG_NONE, &open_as_bookmarks_editor, 0,
- N_("Launch the bookmarks editor"),
- NULL },
- { "reload-plugins", '\0', POPT_ARG_NONE, &reload_plugins, 0, NULL, NULL },
- { NULL, 0, 0, NULL, 0, NULL, NULL }
+ { "sm-client-id", 0, 0, G_OPTION_ARG_STRING, &sm_client_id,
+ "Specify session management ID", "ID" },
+ { "sm-config-prefix", 0, 0, G_OPTION_ARG_STRING, &sm_config_prefix,
+ "Specify prefix of saved configuration", "PREFIX" },
+ { "sm-disable", 0, 0, G_OPTION_ARG_NONE, &sm_disable,
+ "Disable connection to session manager", NULL },
+ { "disable-crash-dialog", 0, 0, G_OPTION_ARG_NONE, &disable_crash_dialog,
+ "Disable Crash Dialog", NULL },
+ { NULL }
};
+#endif /* !GNOME_PARAM_GOPTION_CONTEXT */
/* adapted from gtk+/gdk/x11/gdkdisplay-x11.c */
static guint32
@@ -111,34 +143,6 @@ get_startup_id (void)
return retval;
}
-static void
-handle_url (GtkAboutDialog *about,
- const char *link,
- gpointer data)
-{
- ephy_shell_new_tab (ephy_shell, NULL, NULL, link,
- EPHY_NEW_TAB_OPEN_PAGE);
-}
-
-static void
-handle_email (GtkAboutDialog *about,
- const char *link,
- gpointer data)
-{
- char *address;
-
- address = g_strdup_printf ("mailto:%s\n", link);
- gnome_vfs_url_show (address);
- g_free (address);
-}
-
-static void
-shell_weak_notify (gpointer data,
- GObject *where_the_object_was)
-{
- gtk_main_quit ();
-}
-
/* Copied from libnautilus/nautilus-program-choosing.c; Needed in case
* we have no DESKTOP_STARTUP_ID (with its accompanying timestamp).
*/
@@ -190,23 +194,284 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
return event.xproperty.time;
}
+static void
+handle_url (GtkAboutDialog *about,
+ const char *link,
+ gpointer data)
+{
+ ephy_shell_new_tab (ephy_shell_get_default (),
+ NULL, NULL, link,
+ EPHY_NEW_TAB_OPEN_PAGE);
+}
+
+static void
+handle_email (GtkAboutDialog *about,
+ const char *link,
+ gpointer data)
+{
+ char *address;
+
+ address = g_strdup_printf ("mailto:%s", link);
+ gnome_vfs_url_show (address);
+ g_free (address);
+}
+
+static void
+shell_weak_notify (gpointer data,
+ GObject *zombie)
+{
+ if (gtk_main_level ())
+ {
+ gtk_main_quit ();
+ }
+}
+
+static void
+dbus_g_proxy_finalized_cb (EphyShell *shell,
+ GObject *zombie)
+{
+ LOG ("dbus_g_proxy_finalized_cb");
+
+ g_object_unref (shell);
+}
+
+/* Gnome session client */
+
+static gboolean
+save_yourself_cb (GnomeClient *client,
+ gint phase,
+ GnomeSaveStyle save_style,
+ gboolean shutdown,
+ GnomeInteractStyle interact_style,
+ gboolean fast,
+ gpointer user_data)
+{
+ EphyShell *shell;
+ EphySession *session;
+ char *argv[] = { NULL, "--load-session", NULL };
+ char *discard_argv[] = { "rm", "-f", NULL };
+ char *tmp, *save_to;
+
+ LOG ("save_yourself_cb");
+
+ /* FIXME FIXME */
+ if (!ephy_shell_get_default ()) return FALSE;
+
+ tmp = g_build_filename (ephy_dot_dir (),
+ "session_gnome-XXXXXX",
+ NULL);
+ save_to = ephy_file_tmp_filename (tmp, "xml");
+ g_free (tmp);
+
+ shell = ephy_shell_get_default ();
+ g_assert (shell != NULL);
+
+ session = EPHY_SESSION (ephy_shell_get_session (shell));
+ g_assert (session != NULL);
+
+ argv[0] = g_get_prgname ();
+ argv[2] = save_to;
+ gnome_client_set_restart_command
+ (client, 3, argv);
+
+ discard_argv[2] = save_to;
+ gnome_client_set_discard_command (client, 3,
+ discard_argv);
+
+ ephy_session_save (session, save_to);
+
+ g_free (save_to);
+
+ return TRUE;
+}
+
+static void
+die_cb (GnomeClient* client,
+ gpointer user_data)
+
+{
+ EphyShell *shell;
+ EphySession *session;
+
+ LOG ("die_cb");
+
+ /* FIXME FIXME */
+ if (!ephy_shell_get_default ()) return;
+
+ shell = ephy_shell_get_default ();
+ g_assert (shell != NULL);
+
+ session = EPHY_SESSION (ephy_shell_get_session (shell));
+ g_assert (session != NULL);
+
+ ephy_session_close (session);
+}
+
+static void
+gnome_session_init (void)
+{
+ GnomeClient *client;
+
+ client = gnome_master_client ();
+
+ g_signal_connect (client, "save_yourself",
+ G_CALLBACK (save_yourself_cb), NULL);
+ g_signal_connect (client, "die",
+ G_CALLBACK (die_cb), NULL);
+}
+
+#if 0
+static char *
+path_from_command_line_arg (const char *arg)
+{
+ char path[PATH_MAX];
+
+ if (realpath (arg, path) != NULL)
+ {
+ return g_strdup (path);
+ }
+ else
+ {
+ return g_strdup (arg);
+ }
+}
+#endif
+
+static gboolean
+open_urls (DBusGProxy *proxy,
+ guint32 user_time,
+ GError **error)
+{
+ EphyShell *shell;
+ int i;
+
+ shell = ephy_shell_get_default ();
+
+ if (remaining_arguments == NULL)
+ {
+ /* Homepage or resume */
+ org_gnome_Epiphany_load_url_async
+ (proxy, "", FALSE, !open_in_new_tab,
+ open_in_new_tab, user_time,
+ ephy_activation_general_purpose_reply, NULL /* FIXME! */);
+ }
+ else
+ {
+ for (i = 0; remaining_arguments[i] != NULL; ++i)
+ {
+ char *path;
+
+ path = remaining_arguments[i];
+ //path = path_from_command_line_arg (args[i]);
+
+ org_gnome_Epiphany_load_url_async
+ (proxy, path, FALSE, !open_in_new_tab,
+ open_in_new_tab, user_time,
+ ephy_activation_general_purpose_reply, NULL /* FIXME */);
+
+ //g_free (path);
+ }
+
+ g_strfreev (remaining_arguments);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+call_dbus_proxy (DBusGProxy *proxy,
+ guint32 user_time,
+ GError **error)
+{
+ EphyShell *shell;
+ gboolean retval = TRUE;
+
+ shell = ephy_shell_get_default ();
+
+ if (open_as_bookmarks_editor)
+ {
+ org_gnome_Epiphany_open_bookmarks_editor_async
+ (proxy, user_time,
+ ephy_activation_general_purpose_reply, shell);
+ }
+ else if (session_filename != NULL)
+ {
+ org_gnome_Epiphany_load_session_async
+ (proxy, session_filename, user_time,
+ ephy_activation_general_purpose_reply, shell);
+ }
+#if 0
+ else if (flags & EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS)
+ {
+ org_gnome_Epiphany_import_bookmarks_async
+ (proxy, string_arg,
+ ephy_activation_general_purpose_reply, shell);
+ }
+ else if (flags & EPHY_SHELL_STARTUP_ADD_BOOKMARK)
+ {
+ org_gnome_Epiphany_add_bookmark_async
+ (proxy, string_arg,
+ ephy_activation_general_purpose_reply, shell);
+ }
+#endif
+ else
+ {
+ /* no need to open the homepage if autoresume returns TRUE;
+ * we already opened session windows */
+ if (!_ephy_dbus_is_name_owner () ||
+ (ephy_session_autoresume
+ (EPHY_SESSION (ephy_shell_get_session (shell)),
+ user_time) == FALSE))
+ {
+ retval = open_urls (proxy, user_time, error);
+ }
+ }
+
+ /* FIXME why? */
+ dbus_g_connection_flush (ephy_dbus_get_bus (ephy_dbus_get_default (), EPHY_DBUS_SESSION));
+
+ return retval;
+}
+
+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 GNOME Web 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[])
+main (int argc,
+ char *argv[])
{
- poptContext context;
- GValue context_as_value = { 0 };
- GnomeProgram *program;
- EphyShellStartupFlags startup_flags;
- const char **args, *string_arg;
+ GOptionContext *option_context;
+ GOptionGroup *option_group;
+ DBusGProxy *proxy;
+ GError *error = NULL;
guint32 user_time;
- gboolean new_instance;
- GError *err = NULL;
+#ifndef GNOME_PARAM_GOPTION_CONTEXT
+ GPtrArray *fake_argv_array;
+#endif
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
- bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
#endif
/* check libxml2 API version epiphany was compiled with against the
@@ -214,15 +479,82 @@ main (int argc, char *argv[])
*/
LIBXML_TEST_VERSION
+ /* Initialise our debug helpers */
+ ephy_debug_init ();
+
/* get this early, since gdk will unset the env var */
user_time = get_startup_id ();
- program = gnome_program_init (PACKAGE, VERSION,
- LIBGNOMEUI_MODULE, argc, argv,
- GNOME_PARAM_POPT_TABLE, popt_options,
- GNOME_PARAM_HUMAN_READABLE_NAME, _("Web Browser"),
- GNOME_PARAM_APP_DATADIR, DATADIR,
- NULL);
+ option_context = g_option_context_new (_("GNOME Web Browser"));
+ option_group = g_option_group_new ("epiphany",
+ N_("GNOME Web Browser"),
+ N_("GNOME Web Browser options"),
+ NULL, NULL);
+ g_option_group_add_entries (option_group, option_entries);
+
+ g_option_context_set_main_group (option_context, option_group);
+
+#ifdef GNOME_PARAM_GOPTION_CONTEXT
+ gnome_program_init (PACKAGE, VERSION,
+ LIBGNOMEUI_MODULE, argc, argv,
+ GNOME_PARAM_GOPTION_CONTEXT, option_context,
+ GNOME_PARAM_HUMAN_READABLE_NAME, _("Web Browser"),
+ GNOME_PARAM_APP_DATADIR, DATADIR,
+ NULL);
+
+#else /* !GNOME_PARAM_GOPTION_CONTEXT */
+
+ option_group = g_option_group_new ("gnome-compat", "GNOME GUI Library",
+ "Show GNOME GUI options", NULL, NULL);
+ g_option_group_set_translation_domain (option_group, "libgnomeui-2.0");
+ g_option_group_add_entries (option_group, libgnome_option_entries);
+ g_option_context_add_group (option_context, option_group);
+
+ /* Add the gtk+ option group, but don't open the default display! */
+ option_group = gtk_get_option_group (FALSE);
+ g_option_context_add_group (option_context, option_group);
+
+ if (!g_option_context_parse (option_context, &argc, &argv, &error))
+ {
+ g_print ("%s\n", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ fake_argv_array = g_ptr_array_new ();
+
+ g_ptr_array_add (fake_argv_array, g_strdup (g_get_prgname ()));
+ if (sm_disable)
+ {
+ g_ptr_array_add (fake_argv_array, g_strdup ("--sm-disable"));
+ }
+ if (sm_client_id != NULL)
+ {
+ g_ptr_array_add (fake_argv_array, g_strdup ("--sm-client-id"));
+ g_ptr_array_add (fake_argv_array, sm_client_id);
+ }
+ if (sm_config_prefix != NULL)
+ {
+ g_ptr_array_add (fake_argv_array, g_strdup ("--sm-config-prefix"));
+ g_ptr_array_add (fake_argv_array, sm_config_prefix);
+ }
+ if (disable_crash_dialog)
+ {
+ g_ptr_array_add (fake_argv_array, g_strdup ("--disable-crash-dialog"));
+ }
+
+ gnome_program_init (PACKAGE, VERSION,
+ LIBGNOMEUI_MODULE,
+ fake_argv_array->len,
+ (char**) fake_argv_array->pdata,
+ GNOME_PARAM_HUMAN_READABLE_NAME, _("Web Browser"),
+ GNOME_PARAM_APP_DATADIR, DATADIR,
+ NULL);
+
+ g_ptr_array_add (fake_argv_array, NULL);
+ g_strfreev ((char**) g_ptr_array_free (fake_argv_array, FALSE));
+
+#endif /* GNOME_PARAM_GOPTION_CONTEXT */
/* Get a timestamp manually if need be */
if (user_time == 0)
@@ -236,90 +568,124 @@ main (int argc, char *argv[])
/* Set default window icon */
gtk_window_set_default_icon_name ("web-browser");
- g_object_get_property (G_OBJECT (program),
- GNOME_PARAM_POPT_CONTEXT,
- g_value_init (&context_as_value, G_TYPE_POINTER));
- context = g_value_get_pointer (&context_as_value);
- args = poptGetArgs (context);
+ startup_error_quark = g_quark_from_static_string ("epiphany-startup-error");
- startup_flags = 0;
- string_arg = NULL;
- if (open_in_new_tab)
- {
- startup_flags |= EPHY_SHELL_STARTUP_TABS;
- }
- else if (open_fullscreen)
- {
- startup_flags |= EPHY_SHELL_STARTUP_FULLSCREEN;
- }
- else if (open_in_existing)
- {
- startup_flags |= EPHY_SHELL_STARTUP_EXISTING_WINDOW;
- }
- else if (open_as_bookmarks_editor)
- {
- startup_flags |= EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR;
- }
- else if (session_filename != NULL)
+ if (!_ephy_dbus_startup (&error))
{
- startup_flags |= EPHY_SHELL_STARTUP_SESSION;
- string_arg = session_filename;
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ show_error_message (&error);
+
+ exit (1);
}
- else if (bookmarks_file != NULL)
+
+ /* If we're remoting, no need to start up any further services,
+ * just forward the call.
+ */
+ if (!_ephy_dbus_is_name_owner ())
{
- startup_flags |= EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS;
- string_arg = bookmarks_file;
+ /* FIXME */
+ proxy = ephy_dbus_get_proxy (ephy_dbus_get_default (), EPHY_DBUS_SESSION);
+ if (proxy == NULL)
+ {
+ error = g_error_new (STARTUP_ERROR_QUARK,
+ 0,
+ "Unable to get DBus proxy; aborting activation."); /* FIXME i18n */
+ }
+
+ if (proxy != NULL &&
+ call_dbus_proxy (proxy, user_time, &error))
+ {
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ exit (0);
+ }
+
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ show_error_message (&error);
+
+ exit (1);
}
- else if (bookmark_url != NULL)
+
+ /* We're not remoting; start our services */
+
+ if (!ephy_file_helpers_init (&error))
{
- startup_flags |= EPHY_SHELL_STARTUP_ADD_BOOKMARK;
- string_arg = bookmark_url;
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ show_error_message (&error);
+
+ exit (1);
}
+ /* init the session manager up here so we can quit while the resume dialogue is shown */
+ gnome_session_init ();
+
+ eel_gconf_monitor_add ("/apps/epiphany/general");
gnome_vfs_init ();
- ephy_debug_init ();
- ephy_file_helpers_init ();
ephy_stock_icons_init ();
- eel_gconf_monitor_add ("/apps/epiphany/general");
- eel_gconf_monitor_add ("/apps/epiphany/lockdown");
- eel_gconf_monitor_add ("/desktop/gnome/lockdown");
/* Extensions may want these, so don't initialize in window-cmds */
gtk_about_dialog_set_url_hook (handle_url, NULL, NULL);
gtk_about_dialog_set_email_hook (handle_email, NULL, NULL);
- ephy_shell_new ();
- g_assert (ephy_shell != NULL);
- new_instance = ephy_shell_startup (ephy_shell, startup_flags,
- user_time,
- args, string_arg, &err);
+ /* Now create the shell */
+ _ephy_shell_create_instance ();
- if (err != NULL)
+ /* Create DBUS proxy */
+ proxy = ephy_dbus_get_proxy (ephy_dbus_get_default (), EPHY_DBUS_SESSION);
+ if (proxy == NULL)
{
- GtkWidget *dialog;
+ error = g_error_new (STARTUP_ERROR_QUARK,
+ 0,
+ "Unable to get DBus proxy; aborting activation."); /* FIXME i18n */
+
+ g_object_unref (ephy_shell_get_default ());
+
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ show_error_message (&error);
- dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
- GTK_BUTTONS_CLOSE,
- GTK_MESSAGE_ERROR, err->message);
- gtk_dialog_run (GTK_DIALOG (dialog));
+ exit (1);
}
- else if (new_instance && ephy_shell)
+
+ g_object_weak_ref (G_OBJECT (proxy),
+ (GWeakNotify) dbus_g_proxy_finalized_cb,
+ g_object_ref (ephy_shell_get_default ()));
+
+ if (!call_dbus_proxy (proxy, user_time, &error))
{
- g_object_weak_ref (G_OBJECT (ephy_shell), shell_weak_notify, NULL);
- ephy_object_idle_unref (ephy_shell);
+ g_object_unref (ephy_shell_get_default ());
+
+ _ephy_dbus_release ();
+
+ gdk_notify_startup_complete ();
+ show_error_message (&error);
- gtk_main ();
+ exit (1);
}
+ /* We'll release the initial reference on idle */
+ g_object_weak_ref (G_OBJECT (ephy_shell), shell_weak_notify, NULL);
+ ephy_object_idle_unref (ephy_shell);
+
+ gtk_main ();
+
+ /* Shutdown */
eel_gconf_monitor_remove ("/apps/epiphany/general");
- eel_gconf_monitor_remove ("/apps/epiphany/lockdown");
- eel_gconf_monitor_remove ("/desktop/gnome/lockdown");
gnome_accelerators_sync ();
ephy_state_save ();
ephy_file_helpers_shutdown ();
gnome_vfs_shutdown ();
xmlCleanupParser ();
- poptFreeContext (context);
+
+ _ephy_dbus_release ();
return 0;
}