]> spindle.queued.net Git - midori/commitdiff
Add --single-process command line option
authorChristian Dywan <christian@twotoasts.de>
Sat, 11 Oct 2008 03:46:26 +0000 (05:46 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sat, 11 Oct 2008 03:53:59 +0000 (05:53 +0200)
docs/user/midori.txt
midori/main.c
midori/midori-view.c

index f582d6500f8853c899c078fa8e5c2d6d22cb2293..f1140c1a6beae407814f6843692765a93bf22743 100644 (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                                       |
-+==============+==============+================================================+
-| -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
index ffb414be9144ce1c80fe957ee3a442bdd6ab158a..13f71fe5d3128c16ef55258955457f823953708d 100644 (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 (
index b3303ce95e2c291bebeb28cfc4ca88baf7b9433c..8303ce3615237534159a49c500267c5674156df1 100644 (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,8 +664,8 @@ midori_view_notify_progress_cb (MidoriView* view,
 }
 
 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;
@@ -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)