[nautilus/gnome-3-14] nautilus-application: Don't trigger activate signal for -n option



commit a5d9bc265fea325a10bf01c7743ee8ee246cee8c
Author: Carlos Soriano <carlos sorian89 gmail com>
Date:   Wed Nov 19 15:21:37 2014 +0100

    nautilus-application: Don't trigger activate signal for -n option
    
    Until now we were using --no-default-window in cases when we wanted to
    manage the icons on the desktop, which is the most common use case of
    this setting.
    
    The problems were:
    - When using --no-default-window for the first inscante, the user
    couldn't open a new window of nautilus, since the only window allowed
    was the desktop one in the first instance. The code was just early
    returning in activate if the private setting of the instance is set.
    - When using --no-default-window for the consecutive instances after
    starting nautilus without --no-default-window it was creating a new
    window anyway, since the first instance doesn't have the setting set in
    its private and the second instance was just calling the activate of the
    first instance. For instance that was happening when the user
    activate/deactivate the show-desktop-icons gsetting, since the
    nautilus-autostart desktop file was running nautilus
    --no-default-window, but the first instance was a instance withouth the
    --no-default-window.
    
    So the solution for both cases is avoiding calling activate if the
    --no-default-window is an arggument, instead of a private setting of the
    instance.
    To avoid calling activate we can return a value less than 0 to the
    GApplication in the handle_local_options function. So if the
    --no-default-window is passed as an argument, we just skip the activate
    call.
    Since when launching consecutive instances they take care of its own
    handle_local_options they can skip as well the activate call redirected
    to the first instance.
    
    Big thanks to Ray Strode for discussion, debugging and base of this
    patch, and Debarshy Ray for discussion and debugging.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737515

 src/nautilus-application.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 25b2b67..f26c8c7 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -83,7 +83,6 @@ struct _NautilusApplicationPriv {
        NautilusFreedesktopDBus *fdb_manager;
 
        gboolean desktop_override;
-       gboolean no_default_window;
 
        NotifyNotification *unmount_notify;
 
@@ -931,9 +930,14 @@ nautilus_application_handle_local_options (GApplication *application,
                self->priv->desktop_override = TRUE;
                g_action_group_activate_action (G_ACTION_GROUP (application),
                                                "close-desktop", NULL);
+       }  else if (g_variant_dict_contains (options, "no-default-window")) {
+               /* We want to avoid trigering the activate signal; so no window is created.
+                * GApplication doesn't call activate if we return a value >= 0.
+                * Use EXIT_SUCCESS since is >= 0. */
+               retval = EXIT_SUCCESS;
+               goto out;
        }
 
-       self->priv->no_default_window = g_variant_dict_contains (options, "no-default-window");
        retval = nautilus_application_handle_file_args (self, options);
 
  out:
@@ -950,10 +954,6 @@ nautilus_application_activate (GApplication *app)
 
        DEBUG ("Calling activate");
 
-       if (self->priv->no_default_window) {
-               return;
-       }
-
        files = g_malloc0 (2 * sizeof (GFile *));
        files[0] = g_file_new_for_path (g_get_home_dir ());
        g_application_open (app, files, 1, "new-window");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]