Add --single-process command line option

This commit is contained in:
Christian Dywan 2008-10-11 05:46:26 +02:00
parent 9f2418d455
commit cee341f407
3 changed files with 45 additions and 18 deletions

View file

@ -124,15 +124,18 @@ your build and may not be available on some platforms.
The following arguments are supported if you call Midori from a command line.
+--------------+--------------+------------------------------------------------+
| Short option | Long option | Function |
+==============+==============+================================================+
+-------+--------------------+------------------------------------------------+
| Short | Long option | Function |
+=======+====================+================================================+
| -s | --single-process | This forces all tabs to be opened inside the |
| | | one single browser process. |
+-------+--------------------+------------------------------------------------+
| -i | --id | This is an internal identifier. It is used to |
| | | spawn child processes for new tabs. Do not use |
| | | it unless you know what you are doing. |
+--------------+--------------+------------------------------------------------+
+-------+--------------------+------------------------------------------------+
| -v | --version | Show version information and exit. |
+--------------+--------------+------------------------------------------------+
+-------+--------------------+------------------------------------------------+
Keyboard shortcuts

View file

@ -1016,10 +1016,14 @@ midori_browser_weak_notify_cb (MidoriBrowser* browser,
G_CALLBACK (midori_browser_session_cb), session, NULL);
}
gboolean
midori_view_single_process (gboolean enable);
int
main (int argc,
char** argv)
{
gboolean single_process;
guint socket_id;
gboolean version;
gchar** uris;
@ -1028,6 +1032,8 @@ main (int argc,
GError* error;
GOptionEntry entries[] =
{
{ "single-process", 's', 0, G_OPTION_ARG_NONE, &single_process,
N_("Run everything in the same process"), NULL },
{ "id", 'i', 0, G_OPTION_ARG_INT, &socket_id,
N_("Internal identifier"), NULL },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version,
@ -1060,7 +1066,6 @@ main (int argc,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
g_set_application_name (_("Midori"));
/* Parse cli options */
socket_id = 0;
@ -1081,6 +1086,7 @@ main (int argc,
{
/* If an ID was specified we create a view in a plug.
This allows us to open views in separate processes. */
g_set_application_name ("midori-plug");
view = g_object_new (MIDORI_TYPE_VIEW, "socket-id", socket_id, NULL);
gtk_widget_show (view);
plug = gtk_plug_new (socket_id);
@ -1091,6 +1097,10 @@ main (int argc,
return 0;
}
if (single_process)
midori_view_single_process (TRUE);
g_set_application_name (_("Midori"));
if (version)
{
g_print (

View file

@ -395,6 +395,15 @@ midori_view_class_init (MidoriViewClass* class)
G_PARAM_READWRITE));
}
gboolean
midori_view_single_process (gboolean enable)
{
static gboolean single_process = FALSE;
if (enable)
single_process = TRUE;
return single_process;
}
#define midori_view_is_socket(view) !view->socket_id
#define midori_view_is_plug(view) view->socket_id > 0
@ -655,7 +664,7 @@ midori_view_notify_progress_cb (MidoriView* view,
}
static void
midori_view_action_cb (MidoriView* view,
midori_view_activate_action_cb (MidoriView* view,
const gchar* action)
{
if (midori_view_is_socket (view))
@ -1517,10 +1526,14 @@ gtk_socket_realize_cb (GtkWidget* socket,
gchar* argv[] = { NULL, "--id", NULL, NULL };
/* Sockets are not supported on all platforms,
or Midori can run in single process mode,
so fallback to working without any socket or plug. */
if (!gtk_socket_get_id (GTK_SOCKET (socket)))
if (!gtk_socket_get_id (GTK_SOCKET (socket))
|| midori_view_single_process (FALSE))
{
gtk_widget_destroy (socket);
/* Fallback to operating without a socket */
gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (view)));
view->socket_id = -1;
midori_view_realize (view);
return;
}
@ -1537,7 +1550,8 @@ gtk_socket_realize_cb (GtkWidget* socket,
if (!success)
{
/* Fallback to operating without a socket */
view->socket_id = 0;
gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (view)));
view->socket_id = -1;
midori_view_realize (view);
g_error_free (error);
@ -1607,13 +1621,13 @@ midori_view_realize_cb (MidoriView* view)
else if (midori_view_is_socket (view))
{
socket = gtk_socket_new ();
gtk_widget_show (socket);
g_signal_connect (socket, "realize",
G_CALLBACK (gtk_socket_realize_cb), view);
g_signal_connect (socket, "plug-removed",
G_CALLBACK (gtk_socket_plug_removed_cb), view);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (view),
GTK_WIDGET (socket));
gtk_widget_show (socket);
}
}
@ -1650,7 +1664,7 @@ midori_view_init (MidoriView* view)
"signal::realize",
midori_view_realize_cb, NULL,
"signal::activate-action",
midori_view_action_cb, NULL,
midori_view_activate_action_cb, NULL,
"signal::console-message",
midori_view_console_message_cb, NULL,
"signal::new-tab",
@ -2233,7 +2247,7 @@ midori_view_get_display_title (MidoriView* view)
{
g_return_val_if_fail (MIDORI_IS_VIEW (view), "about:blank");
if (view->title && !strcmp (view->title, ""))
if (!view->uri || (view->title && !strcmp (view->title, "")))
return "about:blank";
if (view->title && *view->title)