aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-main.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@src.gnome.org>2003-11-13 22:02:03 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-11-13 22:02:03 +0800
commitf96998042311fdbe13591635b4861f6e9db7c230 (patch)
treeed45fb5150f213180392d71f4563ac0d86eec9d7 /src/ephy-main.c
parentf6bdfce7e16b98825598dc990efef0846efdb079 (diff)
downloadgsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar.gz
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar.bz2
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar.lz
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar.xz
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.tar.zst
gsoc2013-epiphany-f96998042311fdbe13591635b4861f6e9db7c230.zip
ChangeLog
Diffstat (limited to 'src/ephy-main.c')
-rw-r--r--src/ephy-main.c261
1 files changed, 62 insertions, 199 deletions
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 80627736c..542cc3c06 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -21,60 +21,32 @@
#endif
#include "ephy-shell.h"
-#include "ephy-automation.h"
-#include "ephy-window.h"
-#include "ephy-file-helpers.h"
-#include "EphyAutomation.h"
#include <libgnomeui/gnome-ui-init.h>
+#include <gtk/gtkmain.h>
#include <gtk/gtkmessagedialog.h>
#include <libgnome/gnome-program.h>
#include <bonobo/bonobo-main.h>
+#include <glib/gi18n.h>
-#define EPHY_FACTORY_OAFIID "OAFIID:GNOME_Epiphany_Automation_Factory"
-
-static gint
-ephy_main_translate_url_arguments (poptContext context, gchar ***urls);
-static gboolean
-ephy_main_start (gpointer data);
-
-GnomeProgram *program;
-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 */
-static gboolean open_in_new_window = FALSE; /* force open in a new window? */
-static gboolean open_fullscreen = FALSE; /* open ephy in full screen ? */
-static gchar *session_filename = NULL; /* the session filename */
-static gchar *bookmark_url = NULL; /* the temp bookmark to add */
-static gchar *bookmarks_file = NULL; /* the bookmarks file to import */
-static gboolean open_as_bookmarks_editor = FALSE; /* --bookmarks-editor */
+static gboolean open_in_existing = FALSE;
+static gboolean open_in_new_tab = FALSE;
+static gboolean open_fullscreen = FALSE;
+static gboolean open_as_bookmarks_editor = FALSE;
static gboolean open_as_nautilus_view = FALSE;
-static gint n_urls;
-static gchar **url;
-static gboolean first_instance;
+static const char *session_filename = NULL;
+static const char *bookmark_url = NULL;
+static const char *bookmarks_file = NULL;
-/* command line argument parsing structure */
static struct poptOption popt_options[] =
{
- { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &bonobo_activation_popt_options, 0, NULL,
- NULL },
{ "new-tab", 'n', POPT_ARG_NONE, &open_in_new_tab, 0,
N_("Open a new tab in an existing Epiphany window"),
NULL },
- { "new-window", 'w', POPT_ARG_NONE, &open_in_new_window, 0,
- N_("Open a new window in an existing Epiphany process"),
- NULL },
- { "noraise", '\0', POPT_ARG_NONE, &noraise, 0,
- N_("Do not raise the window when opening a page in an existing Epiphany process"),
- NULL },
{ "fullscreen", 'f', POPT_ARG_NONE, &open_fullscreen, 0,
N_("Run Epiphany in full screen mode"),
NULL },
- { "existing", 'x', POPT_ARG_NONE, &open_in_existing, 0,
- N_("Attempt to load URL in existing Epiphany window"),
- NULL },
{ "load-session", 'l', POPT_ARG_STRING, &session_filename, 0,
N_("Load the given session file"),
N_("FILE") },
@@ -90,18 +62,26 @@ static struct poptOption popt_options[] =
{ "bookmarks-editor", 'b', POPT_ARG_NONE, &open_as_bookmarks_editor, 0,
N_("Launch the bookmarks editor"),
NULL },
-
- /* terminator, must be last */
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
+static void
+shell_weak_notify (gpointer data,
+ GObject *where_the_object_was)
+{
+ gtk_main_quit ();
+}
+
int
main (int argc, char *argv[])
{
poptContext context;
GValue context_as_value = { 0 };
GnomeProgram *program;
- CORBA_Object factory;
+ EphyShellStartupFlags startup_flags;
+ const char **args, *string_arg;
+ gboolean new_instance;
+ GError *err = NULL;
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
@@ -109,8 +89,8 @@ main (int argc, char *argv[])
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
#endif
- g_set_application_name (_("Epiphany Web Browser"));
+ g_set_application_name (_("Epiphany Web Browser"));
program = gnome_program_init (PACKAGE, VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PARAM_POPT_TABLE, popt_options,
@@ -121,188 +101,71 @@ main (int argc, char *argv[])
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);
+ poptFreeContext (context);
- /* load arguments that aren't regular options (urls to load) */
- n_urls = ephy_main_translate_url_arguments (context, &url);
-
- g_value_unset (&context_as_value);
-
- factory = bonobo_activation_activate_from_id
- (EPHY_FACTORY_OAFIID,
- Bonobo_ACTIVATION_FLAG_EXISTING_ONLY,
- NULL, NULL);
-
- if (factory != NULL)
+ startup_flags = 0;
+ string_arg = NULL;
+ if (open_in_new_tab)
{
- first_instance = FALSE;
- ephy_main_start (NULL);
+ startup_flags |= EPHY_SHELL_STARTUP_TABS;
}
- else
+ else if (open_fullscreen)
{
- first_instance = TRUE;
-
- ephy_shell_new ();
-
- g_idle_add ((GSourceFunc) ephy_main_start, NULL);
-
- bonobo_main ();
+ startup_flags |= EPHY_SHELL_STARTUP_FULLSCREEN;
}
-
- return 0;
-}
-
-static gboolean
-ephy_main_start (gpointer data)
-{
- GNOME_EphyAutomation gaserver;
- int i;
-
- CORBA_exception_init (&corba_env);
-
- gaserver = bonobo_activation_activate_from_id ("OAFIID:GNOME_Epiphany_Automation",
- 0, NULL, &corba_env);
-
- if (gaserver == NULL)
+ else if (open_in_existing)
{
- GtkWidget *dialog;
- dialog = gtk_message_dialog_new
- (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Epiphany can't be used now. "
- "Running the command \"bonobo-slay\" "
- "from the console may fix the problem. If not, "
- "you can try rebooting the computer or "
- "installing Epiphany again.\n\n"
- "Bonobo couldn't locate the GNOME_Epiphany_Automation.server."));
- gtk_dialog_run (GTK_DIALOG (dialog));
-
+ startup_flags |= EPHY_SHELL_STARTUP_EXISTING_WINDOW;
}
- /* Launch the bookmarks editor */
else if (open_as_bookmarks_editor)
{
- GNOME_EphyAutomation_openBookmarksEditor
- (gaserver, &corba_env);
- }
- /* load the session if requested */
- else if (session_filename)
- {
- GNOME_EphyAutomation_loadSession
- (gaserver, session_filename, &corba_env);
- }
- /* if we're given a bookmarks file to import... */
- else if (bookmarks_file != NULL)
- {
- GNOME_EphyAutomation_importBookmarks
- (gaserver, bookmarks_file, &corba_env);
+ startup_flags |= EPHY_SHELL_STARTUP_BOOKMARKS_EDITOR;
}
- /* if found and we're given a bookmark to add... */
- else if (bookmark_url != NULL)
+ else if (open_as_nautilus_view)
{
- GNOME_EphyAutomation_addBookmark
- (gaserver, bookmark_url, &corba_env);
+ startup_flags |= EPHY_SHELL_STARTUP_NAUTILUS_VIEW;
}
- /* provided with urls? */
- else if (!open_as_nautilus_view)
+ else if (session_filename != NULL)
{
- /* open all of the urls */
- for (i = 0; i < n_urls; i++)
- {
- GNOME_EphyAutomation_loadurl
- (gaserver, url[i],
- open_fullscreen,
- open_in_existing,
- open_in_new_window,
- open_in_new_tab,
- !noraise,
- &corba_env);
- }
+ startup_flags |= EPHY_SHELL_STARTUP_SESSION;
+ string_arg = session_filename;
}
-
- /* Unref so it will exit if no more used
- * If started with --nautilus-view, only exit when the
- * last view has been destroyed.
- */
- if (first_instance && !open_as_nautilus_view)
+ else if (bookmarks_file != NULL)
{
- g_object_unref (G_OBJECT(ephy_shell));
+ startup_flags |= EPHY_SHELL_STARTUP_IMPORT_BOOKMARKS;
+ string_arg = bookmarks_file;
}
-
- if (gaserver)
+ else if (bookmark_url != NULL)
{
- bonobo_object_release_unref (gaserver, &corba_env);
+ startup_flags |= EPHY_SHELL_STARTUP_ADD_BOOKMARK;
+ string_arg = bookmark_url;
}
- CORBA_exception_free (&corba_env);
-
- gdk_notify_startup_complete ();
+ bonobo_activate ();
- return FALSE;
-}
-
-/* dummy argument to open a default window */
-static gint
-ephy_main_dummy_url_argument (gchar ***urls)
-{
- *urls = g_new0 (gchar *, 2);
+ ephy_shell = ephy_shell_new ();
+ new_instance = ephy_shell_startup (ephy_shell, startup_flags,
+ args, string_arg, &err);
- (*urls)[0] = g_strdup ("");
- (*urls)[1] = NULL;
-
- return 1;
-}
-
-/**
- * translate_url_arguments: gather URL arguments and expand them fully
- * with realpath if they're filenames
- */
-static gint
-ephy_main_translate_url_arguments (poptContext context, gchar ***urls)
-{
- gchar buffer[PATH_MAX];
- gchar **args;
- gint i, n;
-
- /* any context remaining? */
- if (context == NULL)
- {
- return ephy_main_dummy_url_argument (urls);
- }
-
- /* get the args and check */
- args = (gchar **) poptGetArgs (context);
- if (args == NULL)
- {
- poptFreeContext (context);
- return ephy_main_dummy_url_argument (urls);
- }
+ if (err != NULL)
+ {
+ GtkWidget *dialog;
- /* count args */
- for (n = 0; args[n] != NULL; n++)
- /* nothing */;
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_BUTTONS_CLOSE,
+ GTK_MESSAGE_ERROR, err->message);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ }
+ else if (new_instance)
+ {
+ g_object_unref (ephy_shell);
- /* allocate pointer array */
- *urls = g_new0 (gchar *, n + 1);
+ g_object_weak_ref (G_OBJECT (ephy_shell), shell_weak_notify, NULL);
- /* 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);
- }
- else
- {
- (*urls)[i] = g_strdup (args[i]);
- }
- }
- poptFreeContext (context);
- (*urls)[i] = NULL;
+ gtk_main ();
+ }
- /* return the number of urls */
- return n;
+ return 0;
}