Add --single-process command line option
This commit is contained in:
parent
9f2418d455
commit
cee341f407
3 changed files with 45 additions and 18 deletions
|
@ -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.
|
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 |
|
| -i | --id | This is an internal identifier. It is used to |
|
||||||
| | | spawn child processes for new tabs. Do not use |
|
| | | spawn child processes for new tabs. Do not use |
|
||||||
| | | it unless you know what you are doing. |
|
| | | it unless you know what you are doing. |
|
||||||
+--------------+--------------+------------------------------------------------+
|
+-------+--------------------+------------------------------------------------+
|
||||||
| -v | --version | Show version information and exit. |
|
| -v | --version | Show version information and exit. |
|
||||||
+--------------+--------------+------------------------------------------------+
|
+-------+--------------------+------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
Keyboard shortcuts
|
Keyboard shortcuts
|
||||||
|
|
|
@ -1016,10 +1016,14 @@ midori_browser_weak_notify_cb (MidoriBrowser* browser,
|
||||||
G_CALLBACK (midori_browser_session_cb), session, NULL);
|
G_CALLBACK (midori_browser_session_cb), session, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
midori_view_single_process (gboolean enable);
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char** argv)
|
char** argv)
|
||||||
{
|
{
|
||||||
|
gboolean single_process;
|
||||||
guint socket_id;
|
guint socket_id;
|
||||||
gboolean version;
|
gboolean version;
|
||||||
gchar** uris;
|
gchar** uris;
|
||||||
|
@ -1028,6 +1032,8 @@ main (int argc,
|
||||||
GError* error;
|
GError* error;
|
||||||
GOptionEntry entries[] =
|
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,
|
{ "id", 'i', 0, G_OPTION_ARG_INT, &socket_id,
|
||||||
N_("Internal identifier"), NULL },
|
N_("Internal identifier"), NULL },
|
||||||
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version,
|
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version,
|
||||||
|
@ -1060,7 +1066,6 @@ main (int argc,
|
||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
textdomain (GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
#endif
|
#endif
|
||||||
g_set_application_name (_("Midori"));
|
|
||||||
|
|
||||||
/* Parse cli options */
|
/* Parse cli options */
|
||||||
socket_id = 0;
|
socket_id = 0;
|
||||||
|
@ -1081,6 +1086,7 @@ main (int argc,
|
||||||
{
|
{
|
||||||
/* If an ID was specified we create a view in a plug.
|
/* If an ID was specified we create a view in a plug.
|
||||||
This allows us to open views in separate processes. */
|
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);
|
view = g_object_new (MIDORI_TYPE_VIEW, "socket-id", socket_id, NULL);
|
||||||
gtk_widget_show (view);
|
gtk_widget_show (view);
|
||||||
plug = gtk_plug_new (socket_id);
|
plug = gtk_plug_new (socket_id);
|
||||||
|
@ -1091,6 +1097,10 @@ main (int argc,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (single_process)
|
||||||
|
midori_view_single_process (TRUE);
|
||||||
|
|
||||||
|
g_set_application_name (_("Midori"));
|
||||||
if (version)
|
if (version)
|
||||||
{
|
{
|
||||||
g_print (
|
g_print (
|
||||||
|
|
|
@ -395,6 +395,15 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
G_PARAM_READWRITE));
|
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_socket(view) !view->socket_id
|
||||||
#define midori_view_is_plug(view) view->socket_id > 0
|
#define midori_view_is_plug(view) view->socket_id > 0
|
||||||
|
|
||||||
|
@ -655,7 +664,7 @@ midori_view_notify_progress_cb (MidoriView* view,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_view_action_cb (MidoriView* view,
|
midori_view_activate_action_cb (MidoriView* view,
|
||||||
const gchar* action)
|
const gchar* action)
|
||||||
{
|
{
|
||||||
if (midori_view_is_socket (view))
|
if (midori_view_is_socket (view))
|
||||||
|
@ -1517,10 +1526,14 @@ gtk_socket_realize_cb (GtkWidget* socket,
|
||||||
gchar* argv[] = { NULL, "--id", NULL, NULL };
|
gchar* argv[] = { NULL, "--id", NULL, NULL };
|
||||||
|
|
||||||
/* Sockets are not supported on all platforms,
|
/* Sockets are not supported on all platforms,
|
||||||
|
or Midori can run in single process mode,
|
||||||
so fallback to working without any socket or plug. */
|
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);
|
midori_view_realize (view);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1550,8 @@ gtk_socket_realize_cb (GtkWidget* socket,
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
/* Fallback to operating without a socket */
|
/* 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);
|
midori_view_realize (view);
|
||||||
|
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
@ -1607,13 +1621,13 @@ midori_view_realize_cb (MidoriView* view)
|
||||||
else if (midori_view_is_socket (view))
|
else if (midori_view_is_socket (view))
|
||||||
{
|
{
|
||||||
socket = gtk_socket_new ();
|
socket = gtk_socket_new ();
|
||||||
|
gtk_widget_show (socket);
|
||||||
g_signal_connect (socket, "realize",
|
g_signal_connect (socket, "realize",
|
||||||
G_CALLBACK (gtk_socket_realize_cb), view);
|
G_CALLBACK (gtk_socket_realize_cb), view);
|
||||||
g_signal_connect (socket, "plug-removed",
|
g_signal_connect (socket, "plug-removed",
|
||||||
G_CALLBACK (gtk_socket_plug_removed_cb), view);
|
G_CALLBACK (gtk_socket_plug_removed_cb), view);
|
||||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (view),
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (view),
|
||||||
GTK_WIDGET (socket));
|
GTK_WIDGET (socket));
|
||||||
gtk_widget_show (socket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1650,7 +1664,7 @@ midori_view_init (MidoriView* view)
|
||||||
"signal::realize",
|
"signal::realize",
|
||||||
midori_view_realize_cb, NULL,
|
midori_view_realize_cb, NULL,
|
||||||
"signal::activate-action",
|
"signal::activate-action",
|
||||||
midori_view_action_cb, NULL,
|
midori_view_activate_action_cb, NULL,
|
||||||
"signal::console-message",
|
"signal::console-message",
|
||||||
midori_view_console_message_cb, NULL,
|
midori_view_console_message_cb, NULL,
|
||||||
"signal::new-tab",
|
"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");
|
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";
|
return "about:blank";
|
||||||
|
|
||||||
if (view->title && *view->title)
|
if (view->title && *view->title)
|
||||||
|
|
Loading…
Reference in a new issue