[nautilus] application: fold one function into only caller



commit 55144869347c604260cfa6538684c2ed9e0b0f19
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Apr 29 17:48:17 2014 +0200

    application: fold one function into only caller

 src/nautilus-application.c |   58 +++++++++++++++++--------------------------
 1 files changed, 23 insertions(+), 35 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index cc4c5c2..42c233c 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -492,39 +492,6 @@ open_window (NautilusApplication *application,
        nautilus_profile_end (NULL);
 }
 
-static void
-open_windows (NautilusApplication *application,
-             gboolean force_new,
-             GFile **files,
-             gint n_files)
-{
-       guint i;
-
-       if (files == NULL || files[0] == NULL) {
-               /* Open a window pointing at the default location. */
-               open_window (application, NULL);
-       } else {
-               /* Open windows at each requested location. */
-               for (i = 0; i < n_files; ++i) {
-                       NautilusWindowSlot *slot = NULL;
-
-                       if (!force_new)
-                               slot = get_window_slot_for_location (application, files[i]);
-
-                       if (!slot) {
-                               open_window (application, files[i]);
-                       } else {
-                               /* We open the location again to update any possible selection */
-                               nautilus_window_slot_open_location (slot, files[i], 0);
-
-                               NautilusWindow *window = nautilus_window_slot_get_window (slot);
-                               nautilus_window_set_active_slot (window, slot);
-                               gtk_window_present (GTK_WINDOW (window));
-                       }
-               }
-       }
-}
-
 void
 nautilus_application_open_location (NautilusApplication *application,
                                    GFile *location,
@@ -569,12 +536,33 @@ nautilus_application_open (GApplication *app,
                           const gchar *hint)
 {
        NautilusApplication *self = NAUTILUS_APPLICATION (app);
+       gboolean force_new = (g_strcmp0 (hint, "new-window") == 0);
+       NautilusWindowSlot *slot = NULL;
+       NautilusWindow *window;
+       GFile *file;
+       gint idx;
 
        DEBUG ("Open called on the GApplication instance; %d files", n_files);
 
-       gboolean force_new = (g_strcmp0 (hint, "new-window") == 0);
+       /* Open windows at each requested location. */
+       for (idx = 0; idx < n_files; idx++) {
+               file = files[idx];
+
+               if (!force_new) {
+                       slot = get_window_slot_for_location (self, file);
+               }
+
+               if (!slot) {
+                       open_window (self, file);
+               } else {
+                       /* We open the location again to update any possible selection */
+                       nautilus_window_slot_open_location (slot, file, 0);
 
-       open_windows (self, force_new, files, n_files);
+                       window = nautilus_window_slot_get_window (slot);
+                       nautilus_window_set_active_slot (window, slot);
+                       gtk_window_present (GTK_WINDOW (window));
+               }
+       }
 }
 
 static gboolean


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