The following arguments are supported if you call Midori from a command line.
-+--------------+--------------+------------------------------------------------+
-| Short option | Long option | Function |
-+==============+==============+================================================+
-| -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. |
-+--------------+--------------+------------------------------------------------+
++-------+--------------------+------------------------------------------------+
+| 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
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;
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,
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
#endif
- g_set_application_name (_("Midori"));
/* Parse cli options */
socket_id = 0;
{
/* 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);
return 0;
}
+ if (single_process)
+ midori_view_single_process (TRUE);
+
+ g_set_application_name (_("Midori"));
if (version)
{
g_print (
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
}
static void
-midori_view_action_cb (MidoriView* view,
- const gchar* action)
+midori_view_activate_action_cb (MidoriView* view,
+ const gchar* action)
{
if (midori_view_is_socket (view))
return;
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;
}
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);
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);
}
}
"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",
{
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)