[nautilus/wip/gbsneto/files-view] view: add interface
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/gbsneto/files-view] view: add interface
- Date: Mon, 17 Aug 2015 11:38:58 +0000 (UTC)
commit f0b7ae59eb993aeb58e2234d4c424feb9a270f8b
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Aug 17 08:33:42 2015 -0300
view: add interface
Nautilus is in the proccess of receiving a places view,
based on GtkFileChooser's one.
To be able to handle that, an abstraction layer is needed
between NautilusFilesView and NautilusWindowSlot, so we factor
out the common data between views.
Add the NautilusView interface, and make NautilusFilesView a
NautilusView implementation.
src/Makefile.am | 2 +
src/nautilus-canvas-view.c | 2 +-
src/nautilus-desktop-canvas-view.c | 9 +-
src/nautilus-files-view.c | 211 ++++++++++++++++++++--------------
src/nautilus-files-view.h | 13 --
src/nautilus-list-view.c | 2 +-
src/nautilus-trash-bar.c | 8 +-
src/nautilus-view.c | 222 ++++++++++++++++++++++++++++++++++++
src/nautilus-view.h | 82 +++++++++++++
src/nautilus-window-slot.c | 87 ++++++++-------
src/nautilus-window-slot.h | 5 +-
11 files changed, 499 insertions(+), 144 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fddb767..2b01996 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -209,6 +209,8 @@ nautilus_SOURCES = \
nautilus-toolbar.h \
nautilus-trash-bar.c \
nautilus-trash-bar.h \
+ nautilus-view.c \
+ nautilus-view.h \
nautilus-window-slot.c \
nautilus-window-slot.h \
nautilus-window-slot-dnd.c \
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 81cc2d8..9d93987 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1162,7 +1162,7 @@ nautilus_canvas_view_reveal_selection (NautilusFilesView *view)
g_return_if_fail (NAUTILUS_IS_CANVAS_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
/* Make sure at least one of the selected items is scrolled into view */
if (selection != NULL) {
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 49910b0..8adaff1 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -607,7 +607,7 @@ trash_link_is_selection (NautilusFilesView *view)
result = FALSE;
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if ((g_list_length (selection) == 1) &&
NAUTILUS_IS_DESKTOP_ICON_FILE (selection->data)) {
@@ -642,6 +642,7 @@ real_update_context_menus (NautilusFilesView *view)
NautilusDesktopCanvasView *desktop_view;
GAction *action;
GActionGroup *view_action_group;
+ GList *selection;
int selection_count;
g_assert (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (view));
@@ -664,13 +665,17 @@ real_update_context_menus (NautilusFilesView *view)
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
/* Stretch */
- selection_count = nautilus_files_view_get_selection_count (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
+ selection_count = g_list_length (selection);
canvas_container = get_canvas_container (desktop_view);
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "stretch");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), selection_count == 1 &&
canvas_container != NULL &&
!nautilus_canvas_container_has_stretch_handles
(canvas_container));
+
+ g_list_free (selection);
+
/* Unstretch */
action = g_action_map_lookup_action (G_ACTION_MAP (view_action_group), "unstretch");
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), canvas_container != NULL &&
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index a6c5c75..90269f3 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -39,6 +39,7 @@
#include "nautilus-properties-window.h"
#include "nautilus-window.h"
#include "nautilus-toolbar.h"
+#include "nautilus-view.h"
#if ENABLE_EMPTY_VIEW
#include "nautilus-empty-view.h"
@@ -146,12 +147,14 @@ enum {
PROP_WINDOW_SLOT = 1,
PROP_SUPPORTS_ZOOMING,
PROP_ICON,
+ PROP_LOCATION,
PROP_VIEW_WIDGET,
+ PROP_IS_SEARCH,
+ PROP_IS_LOADING,
NUM_PROPERTIES
};
static guint signals[LAST_SIGNAL];
-static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static GdkAtom copied_files_atom;
@@ -163,6 +166,7 @@ struct NautilusFilesViewDetails
NautilusWindowSlot *slot;
NautilusDirectory *model;
NautilusFile *directory_as_file;
+ GFile *location;
guint dir_merge_id;
gint duplicated_label_timeout_id;
@@ -302,7 +306,14 @@ static void update_templates_directory (NautilusFilesVie
static void check_empty_states (NautilusFilesView *view);
-G_DEFINE_TYPE (NautilusFilesView, nautilus_files_view, GTK_TYPE_OVERLAY);
+static gboolean nautilus_files_view_is_search (NautilusView *view);
+
+static void nautilus_files_view_iface_init (NautilusViewInterface *view);
+
+G_DEFINE_TYPE_WITH_CODE (NautilusFilesView,
+ nautilus_files_view,
+ GTK_TYPE_OVERLAY,
+ G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_VIEW, nautilus_files_view_iface_init));
static const struct {
unsigned int keyval;
@@ -331,7 +342,7 @@ check_empty_states (NautilusFilesView *view)
NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES);
filtered = nautilus_file_list_filter_hidden (files, show_hidden_files);
if (g_list_length (filtered) == 0) {
- if (nautilus_files_view_is_search (view)) {
+ if (nautilus_files_view_is_search (NAUTILUS_VIEW (view))) {
gtk_widget_show (view->details->no_search_results_widget);
} else {
gtk_widget_show (view->details->folder_is_empty_widget);
@@ -373,7 +384,7 @@ real_setup_loading_floating_bar (NautilusFilesView *view)
nautilus_floating_bar_cleanup_actions (NAUTILUS_FLOATING_BAR (view->details->floating_bar));
nautilus_floating_bar_set_primary_label (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
- nautilus_files_view_is_search (view) ? _("Searching…") :
_("Loading…"));
+ nautilus_files_view_is_search (NAUTILUS_VIEW (view)) ?
_("Searching…") : _("Loading…"));
nautilus_floating_bar_set_details_label (NAUTILUS_FLOATING_BAR (view->details->floating_bar), NULL);
nautilus_floating_bar_set_show_spinner (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
view->details->loading);
nautilus_floating_bar_add_action (NAUTILUS_FLOATING_BAR (view->details->floating_bar),
@@ -628,18 +639,18 @@ nautilus_files_view_using_manual_layout (NautilusFilesView *view)
/**
* nautilus_files_view_get_icon:
- * @view: a #NautilusFilesView
+ * @view: a #NautilusView
*
* Retrieves the #GIcon that represents @view.
*
* Returns: (transfer none): the #Gicon that represents @view
*/
-GIcon*
-nautilus_files_view_get_icon (NautilusFilesView *view)
+static GIcon*
+nautilus_files_view_get_icon (NautilusView *view)
{
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
- return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_icon (view);
+ return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_icon (NAUTILUS_FILES_VIEW (view));
}
/**
@@ -651,12 +662,12 @@ nautilus_files_view_get_icon (NautilusFilesView *view)
*
* Returns: (transfer none): a #GtkWidget for the view menu
*/
-GtkWidget*
-nautilus_files_view_get_view_widget (NautilusFilesView *view)
+static GtkWidget*
+nautilus_files_view_get_view_widget (NautilusView *view)
{
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
- return view->details->view_menu_widget;
+ return NAUTILUS_FILES_VIEW (view)->details->view_menu_widget;
}
/**
@@ -825,12 +836,16 @@ nautilus_files_view_restore_default_zoom_level (NautilusFilesView *view)
}
gboolean
-nautilus_files_view_is_search (NautilusFilesView *view)
+nautilus_files_view_is_search (NautilusView *view)
{
- if (!view->details->model)
+ NautilusFilesView *files_view;
+
+ files_view = NAUTILUS_FILES_VIEW (view);
+
+ if (!files_view->details->model)
return FALSE;
- return NAUTILUS_IS_SEARCH_DIRECTORY (view->details->model);
+ return NAUTILUS_IS_SEARCH_DIRECTORY (files_view->details->model);
}
const char *
@@ -864,12 +879,12 @@ nautilus_files_view_scroll_to_file (NautilusFilesView *view,
* Return value: GList of NautilusFile pointers representing the selection.
*
**/
-GList *
-nautilus_files_view_get_selection (NautilusFilesView *view)
+static GList*
+nautilus_files_view_get_selection (NautilusView *view)
{
g_return_val_if_fail (NAUTILUS_IS_FILES_VIEW (view), NULL);
- return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection (view);
+ return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->get_selection (NAUTILUS_FILES_VIEW
(view));
}
typedef struct {
@@ -1122,7 +1137,7 @@ nautilus_files_view_activate_selection (NautilusFilesView *view)
{
GList *selection;
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
nautilus_files_view_activate_files (view,
selection,
0,
@@ -1186,7 +1201,7 @@ action_open_file_and_close_window (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
nautilus_files_view_activate_files (view,
selection,
NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND,
@@ -1246,7 +1261,7 @@ action_open_item_location (GSimpleAction *action,
NautilusFile *location;
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if (!selection)
return;
@@ -1274,7 +1289,7 @@ action_open_item_new_tab (GSimpleAction *action,
GtkWindow *window;
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
window = nautilus_files_view_get_containing_window (view);
@@ -1350,7 +1365,7 @@ open_with_other_program (NautilusFilesView *view)
g_assert (NAUTILUS_IS_FILES_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
choose_program (view, selection);
}
@@ -2256,7 +2271,7 @@ action_properties (GSimpleAction *action,
g_assert (NAUTILUS_IS_FILES_VIEW (user_data));
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if (g_list_length (selection) == 0) {
if (view->details->directory_as_file != NULL) {
files = g_list_append (NULL, nautilus_file_ref (view->details->directory_as_file));
@@ -2356,7 +2371,7 @@ action_open_item_new_window (GSimpleAction *action,
GList *selection;
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
window = GTK_WINDOW (nautilus_files_view_get_containing_window (view));
if (nautilus_files_view_confirm_multiple (window, g_list_length (selection), TRUE)) {
@@ -2718,23 +2733,9 @@ nautilus_files_view_grab_focus (GtkWidget *widget)
}
}
-int
-nautilus_files_view_get_selection_count (NautilusFilesView *view)
-{
- /* FIXME: This could be faster if we special cased it in subclasses */
- GList *files;
- int len;
-
- files = nautilus_files_view_get_selection (NAUTILUS_FILES_VIEW (view));
- len = g_list_length (files);
- nautilus_file_list_free (files);
-
- return len;
-}
-
-void
-nautilus_files_view_set_selection (NautilusFilesView *nautilus_files_view,
- GList *selection)
+static void
+nautilus_files_view_set_selection (NautilusView *nautilus_files_view,
+ GList *selection)
{
NautilusFilesView *view;
@@ -2828,6 +2829,7 @@ nautilus_files_view_destroy (GtkWidget *object)
if (view->details->directory_as_file) {
nautilus_file_unref (view->details->directory_as_file);
view->details->directory_as_file = NULL;
+ g_set_object (&view->details->location, NULL);
}
/* We don't own the slot, so no unref */
@@ -2895,7 +2897,7 @@ nautilus_files_view_display_selection_info (NautilusFilesView *view)
g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
folder_item_count_known = TRUE;
folder_count = 0;
@@ -3048,15 +3050,15 @@ nautilus_files_view_send_selection_change (NautilusFilesView *view)
g_signal_emit (view, signals[SELECTION_CHANGED], 0);
}
-void
-nautilus_files_view_load_location (NautilusFilesView *nautilus_files_view,
- GFile *location)
+static void
+nautilus_files_view_set_location (NautilusView *view,
+ GFile *location)
{
NautilusDirectory *directory;
nautilus_profile_start (NULL);
directory = nautilus_directory_get (location);
- load_directory (nautilus_files_view, directory);
+ load_directory (NAUTILUS_FILES_VIEW (view), directory);
nautilus_directory_unref (directory);
nautilus_profile_end (NULL);
}
@@ -3098,7 +3100,7 @@ done_loading (NautilusFilesView *view,
selection = view->details->pending_selection;
- if (nautilus_files_view_is_search (view) && all_files_seen) {
+ if (nautilus_files_view_is_search (NAUTILUS_VIEW (view)) && all_files_seen) {
nautilus_files_view_select_first (view);
do_reveal = TRUE;
} else if (selection != NULL && all_files_seen) {
@@ -3132,6 +3134,7 @@ done_loading (NautilusFilesView *view,
view->details->loading = FALSE;
g_signal_emit (view, signals[END_LOADING], 0, all_files_seen);
+ g_object_notify (G_OBJECT (view), "is-loading");
check_empty_states (view);
@@ -3529,7 +3532,7 @@ process_old_files (NautilusFilesView *view)
check_empty_states (view);
if (files_changed != NULL) {
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
files = file_and_directory_list_to_files (files_changed);
send_selection_change = eel_g_lists_sort_and_check_for_intersection
(&files, &selection);
@@ -4143,7 +4146,7 @@ get_extension_selection_menu_items (NautilusFilesView *view)
GList *selection;
window = nautilus_files_view_get_window (view);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_MENU_PROVIDER);
items = NULL;
@@ -4552,7 +4555,7 @@ run_script (GSimpleAction *action,
old_working_dir = change_to_view_directory (launch_parameters->directory_view);
- selected_files = nautilus_files_view_get_selection (launch_parameters->directory_view);
+ selected_files = nautilus_view_get_selection (NAUTILUS_VIEW (launch_parameters->directory_view));
set_script_environment_variables (launch_parameters->directory_view, selected_files);
parameters = get_file_names_as_parameter_array (selected_files,
@@ -5514,7 +5517,7 @@ action_paste_files_into (GSimpleAction *action,
GList *selection;
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if (selection != NULL) {
paste_into (view, NAUTILUS_FILE (selection->data));
nautilus_file_list_free (selection);
@@ -5562,7 +5565,7 @@ real_action_rename (NautilusFilesView *view,
g_assert (NAUTILUS_IS_FILES_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if (selection_not_empty_in_menu_callback (view, selection)) {
/* If there is more than one file selected, invoke a batch renamer */
@@ -5815,7 +5818,7 @@ action_mount_volume (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -5842,7 +5845,7 @@ action_unmount_volume (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -5868,7 +5871,7 @@ action_eject_volume (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -5922,7 +5925,7 @@ action_start_volume (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -5947,7 +5950,7 @@ action_stop_volume (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -5973,7 +5976,7 @@ action_detect_media (GSimpleAction *action,
view = NAUTILUS_FILES_VIEW (user_data);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
@@ -6295,12 +6298,12 @@ real_update_actions_state (NautilusFilesView *view)
view_action_group = view->details->view_action_group;
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
selection_count = g_list_length (selection);
selection_contains_special_link = special_link_in_selection (selection);
selection_contains_desktop_or_home_dir = desktop_or_home_dir_in_selection (selection);
selection_contains_recent = showing_recent_directory (view);
- selection_contains_search = nautilus_files_view_is_search (view);
+ selection_contains_search = nautilus_files_view_is_search (NAUTILUS_VIEW (view));
selection_is_read_only = selection_count == 1 &&
(!nautilus_file_can_write (NAUTILUS_FILE (selection->data)) &&
!nautilus_file_has_activation_uri (NAUTILUS_FILE (selection->data)));
@@ -6357,7 +6360,7 @@ real_update_actions_state (NautilusFilesView *view)
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), can_create_files);
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
selection_count = g_list_length (selection);
show_app = show_run = item_opens_in_view = selection_count != 0;
@@ -6609,7 +6612,7 @@ update_selection_menu (NautilusFilesView *view)
gboolean show_detect_media;
GDriveStartStopType start_stop_type;
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
selection_count = g_list_length (selection);
show_mount = (selection != NULL);
@@ -7016,7 +7019,7 @@ nautilus_files_view_notify_selection_changed (NautilusFilesView *view)
g_return_if_fail (NAUTILUS_IS_FILES_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
window = nautilus_files_view_get_containing_window (view);
DEBUG_FILES (selection, "Selection changed in window %p", window);
nautilus_file_list_free (selection);
@@ -7082,6 +7085,7 @@ load_directory (NautilusFilesView *view,
g_signal_emit (view, signals[CLEAR], 0);
view->details->loading = TRUE;
+ g_object_notify (G_OBJECT (view), "is-loading");
setup_loading_floating_bar (view);
@@ -7105,8 +7109,12 @@ load_directory (NautilusFilesView *view,
old_file = view->details->directory_as_file;
view->details->directory_as_file =
nautilus_directory_get_corresponding_file (directory);
+ view->details->location = nautilus_file_get_location (view->details->directory_as_file);
nautilus_file_unref (old_file);
+ g_object_notify (G_OBJECT (view), "is-search");
+ g_object_notify (G_OBJECT (view), "location");
+
/* FIXME bugzilla.gnome.org 45062: In theory, we also need to monitor metadata here (as
* well as doing a call when ready), in case external forces
* change the directory's file metadata.
@@ -7572,11 +7580,23 @@ nautilus_files_view_get_property (GObject *object,
switch (prop_id) {
case PROP_ICON:
- g_value_set_object (value, nautilus_files_view_get_icon (view));
+ g_value_set_object (value, nautilus_view_get_icon (NAUTILUS_VIEW (view)));
+ break;
+
+ case PROP_LOCATION:
+ g_value_set_object (value, view->details->location);
break;
case PROP_VIEW_WIDGET:
- g_value_set_object (value, nautilus_files_view_get_view_widget (view));
+ g_value_set_object (value, nautilus_files_view_get_view_widget (NAUTILUS_VIEW (view)));
+ break;
+
+ case PROP_IS_LOADING:
+ g_value_set_boolean (value, nautilus_files_view_get_loading (view));
+ break;
+
+ case PROP_IS_SEARCH:
+ g_value_set_boolean (value, nautilus_view_is_search (NAUTILUS_VIEW (view)));
break;
default:
@@ -7613,6 +7633,11 @@ nautilus_files_view_set_property (GObject *object,
case PROP_SUPPORTS_ZOOMING:
directory_view->details->supports_zooming = g_value_get_boolean (value);
break;
+
+ case PROP_LOCATION:
+ nautilus_files_view_set_location (NAUTILUS_VIEW (directory_view), g_value_get_object
(value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -7791,6 +7816,29 @@ nautilus_files_view_key_press_event (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
+static GFile*
+nautilus_files_view_get_location (NautilusView *view)
+{
+ NautilusFilesView *files_view;
+
+ files_view = NAUTILUS_FILES_VIEW (view);
+
+ return files_view->details->location;
+}
+
+static void
+nautilus_files_view_iface_init (NautilusViewInterface *iface)
+{
+ iface->get_icon = nautilus_files_view_get_icon;
+ iface->get_location = nautilus_files_view_get_location;
+ iface->set_location = nautilus_files_view_set_location;
+ iface->get_selection = nautilus_files_view_get_selection;
+ iface->set_selection = nautilus_files_view_set_selection;
+ iface->get_view_widget = nautilus_files_view_get_view_widget;
+ iface->is_search = nautilus_files_view_is_search;
+}
+
+
static void
nautilus_files_view_class_init (NautilusFilesViewClass *klass)
{
@@ -7896,35 +7944,30 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE);
- properties[PROP_WINDOW_SLOT] =
+ g_object_class_install_property (
+ oclass,
+ PROP_WINDOW_SLOT,
g_param_spec_object ("window-slot",
"Window Slot",
"The parent window slot reference",
NAUTILUS_TYPE_WINDOW_SLOT,
G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY);
- properties[PROP_SUPPORTS_ZOOMING] =
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (
+ oclass,
+ PROP_SUPPORTS_ZOOMING,
g_param_spec_boolean ("supports-zooming",
"Supports zooming",
"Whether the view supports zooming",
TRUE,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
- properties[PROP_ICON] =
- g_param_spec_object ("icon",
- "Icon",
- "The icon that represents the view",
- G_TYPE_ICON,
- G_PARAM_READABLE);
-
- properties[PROP_VIEW_WIDGET] =
- g_param_spec_object ("view-widget",
- "View widget",
- "The view's widget that will appear under the view menu button",
- GTK_TYPE_WIDGET,
- G_PARAM_READABLE);
-
- g_object_class_install_properties (oclass, NUM_PROPERTIES, properties);
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_override_property (oclass, PROP_ICON, "icon");
+ g_object_class_override_property (oclass, PROP_LOCATION, "location");
+ g_object_class_override_property (oclass, PROP_VIEW_WIDGET, "view-widget");
+ g_object_class_override_property (oclass, PROP_IS_LOADING, "is-loading");
+ g_object_class_override_property (oclass, PROP_IS_SEARCH, "is-search");
}
static void
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index 606a054..a0d5ff1 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -359,14 +359,6 @@ void nautilus_files_view_new_file_with_initial_contents (NautilusFi
/* selection handling */
void nautilus_files_view_activate_selection (NautilusFilesView *view);
-int nautilus_files_view_get_selection_count (NautilusFilesView *view);
-GList * nautilus_files_view_get_selection (NautilusFilesView *view);
-void nautilus_files_view_set_selection (NautilusFilesView *view,
- GList *selection);
-
-
-void nautilus_files_view_load_location (NautilusFilesView *view,
- GFile *location);
void nautilus_files_view_stop_loading (NautilusFilesView *view);
char * nautilus_files_view_get_first_visible_file (NautilusFilesView *view);
@@ -392,10 +384,5 @@ void nautilus_files_view_action_show_hidden_files (NautilusFilesV
GActionGroup * nautilus_files_view_get_action_group (NautilusFilesView *view);
GtkWidget* nautilus_files_view_get_content_widget (NautilusFilesView *view);
-gboolean nautilus_files_view_is_search (NautilusFilesView *view);
-
-GIcon* nautilus_files_view_get_icon (NautilusFilesView *view);
-
-GtkWidget* nautilus_files_view_get_view_widget (NautilusFilesView *view);
#endif /* NAUTILUS_FILES_VIEW_H */
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 195a6e3..f835d1b 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1130,7 +1130,7 @@ nautilus_list_view_reveal_selection (NautilusFilesView *view)
g_return_if_fail (NAUTILUS_IS_LIST_VIEW (view));
- selection = nautilus_files_view_get_selection (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
/* Make sure at least one of the selected items is scrolled into view */
if (selection != NULL) {
diff --git a/src/nautilus-trash-bar.c b/src/nautilus-trash-bar.c
index 0508198..e20d0e2 100644
--- a/src/nautilus-trash-bar.c
+++ b/src/nautilus-trash-bar.c
@@ -57,13 +57,17 @@ static void
selection_changed_cb (NautilusFilesView *view,
NautilusTrashBar *bar)
{
+ GList *selection;
int count;
- count = nautilus_files_view_get_selection_count (view);
+ selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
+ count = g_list_length (selection);
gtk_info_bar_set_response_sensitive (GTK_INFO_BAR (bar),
TRASH_BAR_RESPONSE_RESTORE,
(count > 0));
+
+ g_list_free (selection);
}
static void
@@ -166,7 +170,7 @@ trash_bar_response_cb (GtkInfoBar *infobar,
nautilus_file_operations_empty_trash (window);
break;
case TRASH_BAR_RESPONSE_RESTORE:
- files = nautilus_files_view_get_selection (bar->priv->view);
+ files = nautilus_view_get_selection (NAUTILUS_VIEW (bar->priv->view));
nautilus_restore_files_from_trash (files, GTK_WINDOW (window));
nautilus_file_list_free (files);
break;
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
new file mode 100644
index 0000000..db3ec69
--- /dev/null
+++ b/src/nautilus-view.c
@@ -0,0 +1,222 @@
+/* nautilus-view.c
+ *
+ * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "nautilus-view.h"
+
+G_DEFINE_INTERFACE (NautilusView, nautilus_view, GTK_TYPE_WIDGET)
+
+static void
+nautilus_view_default_init (NautilusViewInterface *iface)
+{
+ /**
+ * NautilusView::icon:
+ *
+ * The #GIcon that represents the view, or %NULL.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("icon",
+ "Icon that represents the view",
+ "The icon that represents the view",
+ G_TYPE_ICON,
+ G_PARAM_READABLE));
+
+ /**
+ * NautilusView::is-loading:
+ *
+ * %TRUE if the view is loading the location, %FALSE otherwise.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("is-loading",
+ "Current view is loading",
+ "Whether the current view is loading the
location or not",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /**
+ * NautilusView::is-search:
+ *
+ * %TRUE if the view is searching, %FALSE otherwise.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("is-search",
+ "Current view is searching",
+ "Whether the current view is searching or
not",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /**
+ * NautilusView::location:
+ *
+ * A #GFile that represents the current location displayed by the view.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("location",
+ "Location of the view",
+ "The current location the view",
+ G_TYPE_FILE,
+ G_PARAM_READWRITE));
+
+ /**
+ * NautilusView::view-widget:
+ *
+ * %TRUE if the view is loading the location, %FALSE otherwise.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_object ("view-widget",
+ "View widget for the menu",
+ "The view widget that appears under the
view menu",
+ GTK_TYPE_WIDGET,
+ G_PARAM_READABLE));
+}
+
+/**
+ * nautilus_view_get_icon:
+ * @view: a #NautilusView
+ *
+ * Retrieves the #GIcon that represents @view.
+ *
+ * Returns: (transfer none): a #GIcon
+ */
+GIcon*
+nautilus_view_get_icon (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_icon, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_icon (view);
+}
+
+/**
+ * nautilus_view_get_location:
+ * @view: a #NautilusView
+ *
+ * Retrieves the current location displayed by @view,
+ * in the form of a #GFile.
+ *
+ * Returns: (transfer none): a #GFile
+ */
+GFile*
+nautilus_view_get_location (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_location, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_location (view);
+}
+
+/**
+ * nautilus_view_set_location:
+ * @view: a #NautilusView
+ * @location: the location to be displayed
+ *
+ * Sets the current location displayed by @view,
+ * in the form of a #GFile.
+ *
+ * Returns:
+ */
+void
+nautilus_view_set_location (NautilusView *view,
+ GFile *location)
+{
+ g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_location);
+
+ NAUTILUS_VIEW_GET_IFACE (view)->set_location (view, location);
+}
+
+/**
+ * nautilus_view_get_selection:
+ * @view: a #NautilusView
+ *
+ * Retrieves the list of selected items of @view.
+ *
+ * Returns: (transfer full): a #GList of the selected files. Free with
+ * @g_list_free after use.
+ */
+GList*
+nautilus_view_get_selection (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_selection, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_selection (view);
+}
+
+/**
+ * nautilus_view_set_selection:
+ * @view: a #NautilusView
+ * @selection: the #GList of selected items
+ *
+ * Sets the current selection of @view.
+ *
+ * Returns:
+ */
+void
+nautilus_view_set_selection (NautilusView *view,
+ GList *selection)
+{
+ g_return_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->set_selection);
+
+ NAUTILUS_VIEW_GET_IFACE (view)->set_selection (view, selection);
+}
+
+/**
+ * nautilus_view_get_view_widget:
+ * @view: a #NautilusView
+ *
+ * Retrieves the view menu widget from @view.
+ *
+ * Returns: (transfer none): the widget displayed under view menu.
+ */
+GtkWidget*
+nautilus_view_get_view_widget (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->get_view_widget, NULL);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->get_view_widget (view);
+}
+
+/**
+ * nautilus_view_is_loading:
+ * @view: a #NautilusView
+ *
+ * Whether @view is loading the current location.
+ *
+ * Returns: %TRUE if @view is loading, %FALSE otherwise.
+ */
+gboolean
+nautilus_view_is_loading (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->is_loading, FALSE);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->is_loading (view);
+}
+
+/**
+ * nautilus_view_is_search:
+ * @view: a #NautilusView
+ *
+ * Whether @view is searching.
+ *
+ * Returns: %TRUE if @view is searching, %FALSE otherwise.
+ */
+gboolean
+nautilus_view_is_search (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_VIEW_GET_IFACE (view)->is_search, FALSE);
+
+ return NAUTILUS_VIEW_GET_IFACE (view)->is_search (view);
+}
diff --git a/src/nautilus-view.h b/src/nautilus-view.h
new file mode 100644
index 0000000..db02b55
--- /dev/null
+++ b/src/nautilus-view.h
@@ -0,0 +1,82 @@
+/* nautilus-view.h
+ *
+ * Copyright (C) 2015 Georges Basile Stavracas Neto <georges stavracas gmail com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef NAUTILUS_VIEW_H
+#define NAUTILUS_VIEW_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_VIEW (nautilus_view_get_type ())
+
+G_DECLARE_INTERFACE (NautilusView, nautilus_view, NAUTILUS, VIEW, GtkWidget)
+
+struct _NautilusViewInterface
+{
+ GTypeInterface parent;
+
+ /* The icon that represents the view */
+ GIcon* (*get_icon) (NautilusView *view);
+
+ /* Current location of the view */
+ GFile* (*get_location) (NautilusView *view);
+ void (*set_location) (NautilusView *view,
+ GFile *location);
+
+ /* Selected items */
+ GList* (*get_selection) (NautilusView *view);
+ void (*set_selection) (NautilusView *view,
+ GList *selection);
+
+ /*
+ * The widget that is displayed under the view menu. When set to NULL, the
+ * button gets insensitive.
+ */
+ GtkWidget* (*get_view_widget) (NautilusView *view);
+
+ /* Whether the current view is loading the location */
+ gboolean (*is_loading) (NautilusView *view);
+
+ /* Whether the current view is searching or not */
+ gboolean (*is_search) (NautilusView *view);
+};
+
+GIcon* nautilus_view_get_icon (NautilusView *view);
+
+GFile* nautilus_view_get_location (NautilusView *view);
+
+void nautilus_view_set_location (NautilusView *view,
+ GFile *location);
+
+GList* nautilus_view_get_selection (NautilusView *view);
+
+void nautilus_view_set_selection (NautilusView *view,
+ GList *selection);
+
+GtkWidget* nautilus_view_get_view_widget (NautilusView *view);
+
+gboolean nautilus_view_is_loading (NautilusView *view);
+
+gboolean nautilus_view_is_search (NautilusView *view);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_VIEW_H */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 9791cfc..b320b3d 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -30,6 +30,7 @@
#include "nautilus-list-view.h"
#include "nautilus-special-location-bar.h"
#include "nautilus-trash-bar.h"
+#include "nautilus-view.h"
#include "nautilus-window.h"
#include "nautilus-x-content-bar.h"
@@ -74,8 +75,8 @@ struct NautilusWindowSlotDetails {
gchar *title;
/* Viewed file */
- NautilusFilesView *content_view;
- NautilusFilesView *new_content_view;
+ NautilusView *content_view;
+ NautilusView *new_content_view;
NautilusFile *viewed_file;
gboolean viewed_file_seen;
gboolean viewed_file_in_trash;
@@ -137,7 +138,7 @@ nautilus_window_slot_sync_search_widgets (NautilusWindowSlot *slot)
nautilus_window_slot_set_search_visible (slot,
slot->details->search_visible ||
(slot->details->content_view &&
- nautilus_files_view_is_search
(slot->details->content_view)));
+ nautilus_view_is_search (slot->details->content_view)));
}
static gboolean
@@ -147,7 +148,7 @@ nautilus_window_slot_content_view_matches_iid (NautilusWindowSlot *slot,
if (slot->details->content_view == NULL) {
return FALSE;
}
- return g_strcmp0 (nautilus_files_view_get_view_id (slot->details->content_view), iid) == 0;
+ return g_strcmp0 (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW
(slot->details->content_view)), iid) == 0;
}
void
@@ -244,7 +245,7 @@ query_editor_activated_callback (NautilusQueryEditor *editor,
NautilusWindowSlot *slot)
{
if (slot->details->content_view != NULL) {
- nautilus_files_view_activate_selection (slot->details->content_view);
+ nautilus_files_view_activate_selection (NAUTILUS_FILES_VIEW (slot->details->content_view));
}
}
@@ -741,7 +742,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
old_selection = NULL;
if (slot->details->content_view != NULL) {
- old_selection = nautilus_files_view_get_selection (slot->details->content_view);
+ old_selection = nautilus_view_get_selection (slot->details->content_view);
}
if (target_window == window && target_slot == slot && !is_desktop &&
@@ -834,7 +835,7 @@ begin_location_change (NautilusWindowSlot *slot,
/* We are going to change the location, so make sure we stop any loading
* or searching of the previous view, so we avoid to be slow */
if (slot->details->content_view) {
- nautilus_files_view_stop_loading (slot->details->content_view);
+ nautilus_files_view_stop_loading (NAUTILUS_FILES_VIEW (slot->details->content_view));
}
/* If there is no new selection and the new location is
@@ -905,7 +906,7 @@ begin_location_change (NautilusWindowSlot *slot,
/* Set current_bookmark scroll pos */
if (slot->details->current_location_bookmark != NULL &&
slot->details->content_view != NULL) {
- current_pos = nautilus_files_view_get_first_visible_file (slot->details->content_view);
+ current_pos = nautilus_files_view_get_first_visible_file (NAUTILUS_FILES_VIEW
(slot->details->content_view));
nautilus_bookmark_set_scroll_pos (slot->details->current_location_bookmark, current_pos);
g_free (current_pos);
}
@@ -1213,7 +1214,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
* so the view mode of the current view will be the one search is using,
* which is not the one we are interested in */
if (slot->details->view_mode_before_search == NULL) {
- slot->details->view_mode_before_search = g_strdup
(nautilus_files_view_get_view_id (slot->details->content_view));
+ slot->details->view_mode_before_search = g_strdup
(nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW (slot->details->content_view)));
}
view_id = g_strdup (NAUTILUS_LIST_VIEW_IID);
} else {
@@ -1231,7 +1232,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
g_free (slot->details->view_mode_before_search);
slot->details->view_mode_before_search = NULL;
} else {
- view_id = g_strdup (nautilus_files_view_get_view_id
(slot->details->content_view));
+ view_id = g_strdup (nautilus_files_view_get_view_id (NAUTILUS_FILES_VIEW
(slot->details->content_view)));
}
}
@@ -1340,7 +1341,7 @@ create_content_view (NautilusWindowSlot *slot,
GError **error_out)
{
NautilusWindow *window;
- NautilusFilesView *view;
+ NautilusView *view;
GList *selection;
gboolean ret = TRUE;
GError *error = NULL;
@@ -1371,7 +1372,7 @@ create_content_view (NautilusWindowSlot *slot,
g_object_ref (view);
} else {
/* create a new content view */
- view = nautilus_files_view_new (view_id, slot);
+ view = NAUTILUS_VIEW (nautilus_files_view_new (view_id, slot));
slot->details->new_content_view = view;
}
@@ -1400,7 +1401,7 @@ create_content_view (NautilusWindowSlot *slot,
slot->details->load_with_search = FALSE;
if (slot->details->pending_selection == NULL) {
- slot->details->pending_selection = nautilus_files_view_get_selection
(slot->details->content_view);
+ slot->details->pending_selection = nautilus_view_get_selection
(slot->details->content_view);
}
}
@@ -1416,7 +1417,7 @@ create_content_view (NautilusWindowSlot *slot,
g_list_free_full (slot->details->pending_selection, g_object_unref);
slot->details->pending_selection = NULL;
} else if (old_location != NULL) {
- selection = nautilus_files_view_get_selection (slot->details->content_view);
+ selection = nautilus_view_get_selection (slot->details->content_view);
load_new_location (slot,
old_location,
selection,
@@ -1448,7 +1449,7 @@ load_new_location (NautilusWindowSlot *slot,
gboolean tell_new_content_view)
{
GList *selection_copy;
- NautilusFilesView *view;
+ NautilusView *view;
g_assert (slot != NULL);
g_assert (location != NULL);
@@ -1460,19 +1461,19 @@ load_new_location (NautilusWindowSlot *slot,
/* Note, these may recurse into report_load_underway */
if (slot->details->content_view != NULL && tell_current_content_view) {
view = slot->details->content_view;
- nautilus_files_view_load_location (slot->details->content_view, location);
+ nautilus_view_set_location (slot->details->content_view, location);
}
if (slot->details->new_content_view != NULL && tell_new_content_view &&
(!tell_current_content_view ||
slot->details->new_content_view != slot->details->content_view) ) {
view = slot->details->new_content_view;
- nautilus_files_view_load_location (slot->details->new_content_view, location);
+ nautilus_view_set_location (slot->details->new_content_view, location);
}
if (view != NULL) {
/* new_content_view might have changed here if
report_load_underway was called from load_location */
- nautilus_files_view_set_selection (view, selection_copy);
+ nautilus_view_set_selection (view, selection_copy);
}
g_list_free_full (selection_copy, g_object_unref);
@@ -1542,7 +1543,7 @@ cancel_location_change (NautilusWindowSlot *slot)
directory = nautilus_directory_get (slot->details->location);
/* Stops current loading or search if any, so we are not slow */
- nautilus_files_view_stop_loading (slot->details->content_view);
+ nautilus_files_view_stop_loading (NAUTILUS_FILES_VIEW (slot->details->content_view));
nautilus_directory_unref (directory);
if (slot->details->pending_location != NULL
@@ -1554,7 +1555,7 @@ cancel_location_change (NautilusWindowSlot *slot)
* be told, or it is the very pending change we wish
* to cancel.
*/
- selection = nautilus_files_view_get_selection (slot->details->content_view);
+ selection = nautilus_view_get_selection (slot->details->content_view);
load_new_location (slot,
location,
selection,
@@ -1637,6 +1638,7 @@ void
nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
const char *id)
{
+ GList *selection;
char *uri;
g_assert (slot != NULL);
@@ -1654,10 +1656,12 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
nautilus_window_slot_set_allow_stop (slot, TRUE);
- if (nautilus_files_view_get_selection_count (slot->details->content_view) == 0) {
+ selection = nautilus_view_get_selection (slot->details->content_view);
+
+ if (g_list_length (selection) == 0) {
/* If there is no selection, queue a scroll to the same icon that
* is currently visible */
- slot->details->pending_scroll_to = nautilus_files_view_get_first_visible_file
(slot->details->content_view);
+ slot->details->pending_scroll_to = nautilus_files_view_get_first_visible_file
(NAUTILUS_FILES_VIEW (slot->details->content_view));
}
slot->details->location_change_type = NAUTILUS_LOCATION_CHANGE_RELOAD;
@@ -1665,6 +1669,8 @@ nautilus_window_slot_set_content_view (NautilusWindowSlot *slot,
/* Just load the homedir. */
nautilus_window_slot_go_home (slot, FALSE);
}
+
+ g_list_free (selection);
}
void
@@ -1740,8 +1746,8 @@ nautilus_window_slot_force_reload (NautilusWindowSlot *slot)
current_pos = NULL;
selection = NULL;
if (slot->details->content_view != NULL) {
- current_pos = nautilus_files_view_get_first_visible_file (slot->details->content_view);
- selection = nautilus_files_view_get_selection (slot->details->content_view);
+ current_pos = nautilus_files_view_get_first_visible_file (NAUTILUS_FILES_VIEW
(slot->details->content_view));
+ selection = nautilus_view_get_selection (slot->details->content_view);
}
begin_location_change
(slot, location, location, selection,
@@ -1763,7 +1769,7 @@ nautilus_window_slot_queue_reload (NautilusWindowSlot *slot)
if (slot->details->pending_location != NULL
|| slot->details->content_view == NULL
- || nautilus_files_view_get_loading (slot->details->content_view)) {
+ || nautilus_view_is_loading (slot->details->content_view)) {
/* there is a reload in flight */
slot->details->needs_reload = TRUE;
return;
@@ -2038,13 +2044,16 @@ static void
nautilus_window_slot_show_trash_bar (NautilusWindowSlot *slot)
{
GtkWidget *bar;
- NautilusFilesView *view;
+ NautilusView *view;
- view = nautilus_window_slot_get_current_view (slot);
- bar = nautilus_trash_bar_new (view);
- gtk_widget_show (bar);
+ view = nautilus_window_slot_get_current_view (slot);
- nautilus_window_slot_add_extra_location_widget (slot, bar);
+ if (NAUTILUS_IS_FILES_VIEW (view)) {
+ bar = nautilus_trash_bar_new (NAUTILUS_FILES_VIEW (view));
+ gtk_widget_show (bar);
+
+ nautilus_window_slot_add_extra_location_widget (slot, bar);
+ }
}
static void
@@ -2135,9 +2144,9 @@ view_end_loading_cb (NautilusFilesView *view,
{
/* Only handle this if we're expecting it.
* Don't handle it if its from an old view we've switched from */
- if (view == slot->details->content_view && all_files_seen) {
+ if (view == NAUTILUS_FILES_VIEW (slot->details->content_view) && all_files_seen) {
if (slot->details->pending_scroll_to != NULL) {
- nautilus_files_view_scroll_to_file (slot->details->content_view,
+ nautilus_files_view_scroll_to_file (NAUTILUS_FILES_VIEW (slot->details->content_view),
slot->details->pending_scroll_to);
}
end_location_change (slot);
@@ -2157,7 +2166,7 @@ view_begin_loading_cb (NautilusFilesView *view,
{
nautilus_profile_start (NULL);
- if (view == slot->details->new_content_view) {
+ if (view == NAUTILUS_FILES_VIEW (slot->details->new_content_view)) {
location_has_really_changed (slot);
} else {
nautilus_window_slot_set_allow_stop (slot, TRUE);
@@ -2522,7 +2531,7 @@ nautilus_window_slot_set_window (NautilusWindowSlot *slot,
}
}
-NautilusFilesView *
+NautilusView *
nautilus_window_slot_get_view (NautilusWindowSlot *slot)
{
return slot->details->content_view;
@@ -2606,7 +2615,7 @@ nautilus_window_slot_get_current_uri (NautilusWindowSlot *slot)
return NULL;
}
-NautilusFilesView *
+NautilusView*
nautilus_window_slot_get_current_view (NautilusWindowSlot *slot)
{
if (slot->details->content_view != NULL) {
@@ -2685,23 +2694,23 @@ nautilus_window_slot_new (NautilusWindow *window)
GIcon*
nautilus_window_slot_get_icon (NautilusWindowSlot *slot)
{
- NautilusFilesView *view;
+ NautilusView *view;
g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), NULL);
view = nautilus_window_slot_get_current_view (slot);
- return view ? nautilus_files_view_get_icon (view) : NULL;
+ return view ? nautilus_view_get_icon (view) : NULL;
}
GtkWidget*
nautilus_window_slot_get_view_widget (NautilusWindowSlot *slot)
{
- NautilusFilesView *view;
+ NautilusView *view;
g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), NULL);
view = nautilus_window_slot_get_current_view (slot);
- return view ? nautilus_files_view_get_view_widget (view) : NULL;
+ return view ? nautilus_view_get_view_widget (view) : NULL;
}
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index fc433ff..95676ea 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -30,6 +30,7 @@ typedef struct NautilusWindowSlotClass NautilusWindowSlotClass;
typedef struct NautilusWindowSlotDetails NautilusWindowSlotDetails;
#include "nautilus-files-view.h"
+#include "nautilus-view.h"
#include "nautilus-window.h"
#define NAUTILUS_TYPE_WINDOW_SLOT (nautilus_window_slot_get_type())
@@ -87,9 +88,9 @@ char * nautilus_window_slot_get_location_uri (NautilusWindowSlot *slot);
NautilusFile * nautilus_window_slot_get_file (NautilusWindowSlot *slot);
NautilusBookmark *nautilus_window_slot_get_bookmark (NautilusWindowSlot *slot);
-NautilusFilesView * nautilus_window_slot_get_view (NautilusWindowSlot *slot);
+NautilusView* nautilus_window_slot_get_view (NautilusWindowSlot *slot);
-NautilusFilesView * nautilus_window_slot_get_current_view (NautilusWindowSlot *slot);
+NautilusView* nautilus_window_slot_get_current_view (NautilusWindowSlot *slot);
char * nautilus_window_slot_get_current_uri (NautilusWindowSlot *slot);
GList * nautilus_window_slot_get_back_history (NautilusWindowSlot *slot);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]