[nautilus/refactor: 5/26] window-slot: cleanup of window_slot_open_location() functions
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/refactor: 5/26] window-slot: cleanup of window_slot_open_location() functions
- Date: Wed, 29 Dec 2010 17:57:53 +0000 (UTC)
commit 65939f93d5793b2d5950306ccf9015b52899f34d
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Dec 21 18:57:39 2010 +0100
window-slot: cleanup of window_slot_open_location() functions
src/file-manager/fm-directory-view.c | 28 ++++---------------
src/nautilus-mime-actions.c | 4 +-
src/nautilus-navigation-window-pane.c | 6 ++--
src/nautilus-places-sidebar.c | 12 ++++----
src/nautilus-spatial-window.c | 6 +++-
src/nautilus-tree-sidebar.c | 8 +++---
src/nautilus-window-manage-views.c | 18 ------------
src/nautilus-window-slot.h | 48 ++++++++++++++++++---------------
src/nautilus-window.c | 17 +++++++-----
9 files changed, 61 insertions(+), 86 deletions(-)
---
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index df871cc..c71c2e3 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -839,26 +839,6 @@ action_open_folder_window_callback (GtkAction *action,
}
static void
-open_location (FMDirectoryView *directory_view,
- const char *new_uri,
- NautilusWindowOpenMode mode,
- NautilusWindowOpenFlags flags)
-{
- GtkWindow *window;
- GFile *location;
-
- g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
- g_assert (new_uri != NULL);
-
- window = fm_directory_view_get_containing_window (directory_view);
- DEBUG ("open_location window=%p: %s", window, new_uri);
- location = g_file_new_for_uri (new_uri);
- nautilus_window_slot_open_location_full (directory_view->details->slot,
- location, mode, flags, NULL, NULL, NULL);
- g_object_unref (location);
-}
-
-static void
app_chooser_dialog_response_cb (GtkDialog *dialog,
gint response_id,
gpointer user_data)
@@ -5678,11 +5658,15 @@ action_open_scripts_folder_callback (GtkAction *action,
gpointer callback_data)
{
FMDirectoryView *view;
+ static GFile *location = NULL;
+
+ if (location == NULL) {
+ location = g_file_new_for_uri (scripts_directory_uri);
+ }
view = FM_DIRECTORY_VIEW (callback_data);
+ nautilus_window_slot_go_to (view->details->slot, location, FALSE);
- open_location (view, scripts_directory_uri, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0);
-
eel_show_info_dialog_with_details
(_("All executable files in this folder will appear in the "
"Scripts menu."),
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 102d8d6..28db719 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -1754,8 +1754,8 @@ activate_files (ActivateParameters *parameters)
uri = nautilus_file_get_activation_uri (file);
f = g_file_new_for_uri (uri);
- nautilus_window_slot_open_location_full (parameters->slot,
- f, parameters->mode, flags, NULL, NULL, NULL);
+ nautilus_window_slot_open_location (parameters->slot,
+ f, parameters->mode, flags, NULL);
g_object_unref (f);
g_free (uri);
}
diff --git a/src/nautilus-navigation-window-pane.c b/src/nautilus-navigation-window-pane.c
index 49ae70c..4c156ed 100644
--- a/src/nautilus-navigation-window-pane.c
+++ b/src/nautilus-navigation-window-pane.c
@@ -260,9 +260,9 @@ path_bar_button_released_callback (GtkWidget *widget,
if (flags != 0) {
slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW_PANE (pane)->window);
- nautilus_window_slot_open_location_full (slot, location,
- NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, NULL, NULL, NULL);
+ nautilus_window_slot_open_location (slot, location,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+ flags, NULL);
g_object_unref (location);
return TRUE;
}
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index d5cd161..c4a743f 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -1739,9 +1739,9 @@ volume_mounted_cb (GVolume *volume,
if (sidebar->go_to_after_mount_slot != NULL) {
if ((sidebar->go_to_after_mount_flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) {
- nautilus_window_slot_open_location_full (sidebar->go_to_after_mount_slot, location,
- NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
- sidebar->go_to_after_mount_flags, NULL, NULL, NULL);
+ nautilus_window_slot_open_location (sidebar->go_to_after_mount_slot, location,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+ sidebar->go_to_after_mount_flags, NULL);
} else {
NautilusApplication *app;
NautilusWindow *new, *cur;
@@ -1817,9 +1817,9 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
/* Navigate to the clicked location */
if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW) == 0) {
slot = nautilus_window_get_active_slot (sidebar->window);
- nautilus_window_slot_open_location_full (slot, location,
- NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, NULL, NULL, NULL);
+ nautilus_window_slot_open_location (slot, location,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+ flags, NULL);
} else {
NautilusWindow *cur, *new;
NautilusApplication *app;
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 766178c..0fdd49d 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -511,8 +511,10 @@ location_menu_item_activated_callback (GtkWidget *menu_item,
close_behind = TRUE;
}
- nautilus_window_slot_open_location_with_selection
- (slot, dest, selection, close_behind);
+ nautilus_window_slot_open_location (slot, dest,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+ NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND,
+ selection);
g_list_free_full (selection, g_object_unref);
}
diff --git a/src/nautilus-tree-sidebar.c b/src/nautilus-tree-sidebar.c
index f7dbec6..84efa49 100644
--- a/src/nautilus-tree-sidebar.c
+++ b/src/nautilus-tree-sidebar.c
@@ -369,12 +369,12 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
DEBUG ("Tree sidebar, opening location %s", uri);
location = g_file_new_for_uri (uri);
- nautilus_window_slot_open_location_full
+ nautilus_window_slot_open_location
(slot,
location,
NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
view->details->activation_flags,
- NULL, NULL, NULL);
+ NULL);
g_object_unref (location);
} else {
DEBUG ("Tree sidebar, launching application for %s", file_uri);
@@ -396,12 +396,12 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
DEBUG ("Tree sidebar, opening location %s", uri);
location = g_file_new_for_uri (uri);
- nautilus_window_slot_open_location_full
+ nautilus_window_slot_open_location
(slot,
location,
NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
view->details->activation_flags,
- NULL, NULL, NULL);
+ NULL);
g_object_unref (location);
}
}
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 0d22e79..55586ff 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -664,24 +664,6 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
}
void
-nautilus_window_slot_open_location_with_selection (NautilusWindowSlot *slot,
- GFile *location,
- GList *selection,
- gboolean close_behind)
-{
- NautilusWindowOpenFlags flags;
-
- flags = 0;
- if (close_behind) {
- flags = NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
- }
- nautilus_window_slot_open_location_full (slot, location,
- NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags, selection, NULL, NULL);
-}
-
-
-void
nautilus_window_slot_go_home (NautilusWindowSlot *slot, gboolean new_tab)
{
GFile *home;
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index d3d0693..f0d0a2f 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -127,17 +127,32 @@ char * nautilus_window_slot_get_location_uri (NautilusWindowSlot *slot);
void nautilus_window_slot_close (NautilusWindowSlot *slot);
void nautilus_window_slot_reload (NautilusWindowSlot *slot);
-void nautilus_window_slot_open_location_with_selection (NautilusWindowSlot *slot,
- GFile *location,
- GList *selection,
- gboolean close_behind);
-void nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
- GFile *location,
- NautilusWindowOpenMode mode,
- NautilusWindowOpenFlags flags,
- GList *new_selection,
- NautilusWindowGoToCallback callback,
- gpointer user_data);
+void nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
+ GFile *location,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags,
+ GList *new_selection,
+ NautilusWindowGoToCallback callback,
+ gpointer user_data);
+
+/* convenience wrapper without callback/user_data */
+#define nautilus_window_slot_open_location(slot, location, mode, flags, new_selection)\
+ nautilus_window_slot_open_location_full(slot, location, mode, flags, new_selection, NULL, NULL)
+
+/* these are wrappers that always open according to current mode */
+#define nautilus_window_slot_go_to(slot, location, new_tab) \
+ nautilus_window_slot_open_location(slot, location, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, \
+ (new_tab ? NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
+ NULL)
+#define nautilus_window_slot_go_to_full(slot, location, new_tab, callback, user_data) \
+ nautilus_window_slot_open_location_full(slot, location, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, \
+ (new_tab ? NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
+ NULL, callback, user_data)
+#define nautilus_window_slot_go_to_with_selection(slot, location, new_selection) \
+ nautilus_window_slot_open_location(slot, location,\
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0,\
+ new_selection)
+
void nautilus_window_slot_stop_loading (NautilusWindowSlot *slot);
void nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
@@ -151,18 +166,7 @@ void nautilus_window_slot_connect_content_view (NautilusW
void nautilus_window_slot_disconnect_content_view (NautilusWindowSlot *slot,
NautilusView *view);
-#define nautilus_window_slot_go_to(slot,location, new_tab) \
- nautilus_window_slot_open_location_full(slot, location, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, \
- (new_tab ? NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
- NULL, NULL, NULL)
-
-#define nautilus_window_slot_go_to_full(slot, location, new_tab, callback, user_data) \
- nautilus_window_slot_open_location_full(slot, location, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, \
- (new_tab ? NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB : 0), \
- NULL, callback, user_data)
-#define nautilus_window_slot_go_to_with_selection(slot,location,new_selection) \
- nautilus_window_slot_open_location_with_selection(slot, location, new_selection, FALSE)
void nautilus_window_slot_go_home (NautilusWindowSlot *slot,
gboolean new_tab);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 8bfd22d..60c9192 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -230,11 +230,15 @@ nautilus_window_go_to_full (NautilusWindow *window,
}
void
-nautilus_window_go_to_with_selection (NautilusWindow *window, GFile *location, GList *new_selection)
+nautilus_window_go_to_with_selection (NautilusWindow *window,
+ GFile *location,
+ GList *new_selection)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- nautilus_window_slot_go_to_with_selection (window->details->active_pane->active_slot, location, new_selection);
+ nautilus_window_slot_go_to_with_selection (window->details->active_pane->active_slot,
+ location,
+ new_selection);
}
static gboolean
@@ -311,11 +315,10 @@ nautilus_window_go_up (NautilusWindow *window, gboolean close_behind, gboolean n
flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
}
- nautilus_window_slot_open_location_full (slot, parent,
- NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
- flags,
- selection,
- NULL, NULL);
+ nautilus_window_slot_open_location (slot, parent,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
+ flags,
+ selection);
g_object_unref (parent);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]