[nautilus/wip/csoriano/destktop-split2: 28/33] files-view: use inheritance for querying special selection
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/destktop-split2: 28/33] files-view: use inheritance for querying special selection
- Date: Mon, 21 Mar 2016 21:41:19 +0000 (UTC)
commit e7aab87817d541a6f7c70c32acfa77857b5752e8
Author: Carlos Soriano <csoriano gnome org>
Date: Fri Mar 18 16:29:42 2016 +0100
files-view: use inheritance for querying special selection
There is a few times that the file cannot be copied, moved etc.
This usually happens with the special links in the desktop.
We were querying whether the selection has special items or not
in the files-view itself. However, this is something that every view
could have special, like the desktop one.
So use inheritance for it.
src/nautilus-desktop-canvas-view.c | 26 +++++++++++++++++++++++++
src/nautilus-files-view.c | 37 +++++++++++------------------------
src/nautilus-files-view.h | 6 +++++
3 files changed, 44 insertions(+), 25 deletions(-)
---
diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 3d7e115..3fabf20 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -69,6 +69,8 @@ static void default_zoom_level_changed (gpointer
static void real_update_context_menus (NautilusFilesView *view);
static char* real_get_backing_uri (NautilusFilesView *view);
static void real_check_empty_states (NautilusFilesView *view);
+static gboolean real_special_link_in_selection (NautilusFilesView *view,
+ GList *selection);
static void nautilus_desktop_canvas_view_update_canvas_container_fonts (NautilusDesktopCanvasView
*view);
static void font_changed_callback (gpointer callback_data);
@@ -295,6 +297,7 @@ nautilus_desktop_canvas_view_class_init (NautilusDesktopCanvasViewClass *class)
vclass->end_loading = nautilus_desktop_canvas_view_end_loading;
vclass->get_backing_uri = real_get_backing_uri;
vclass->check_empty_states = real_check_empty_states;
+ vclass->special_link_in_selection = real_special_link_in_selection;
g_type_class_add_private (class, sizeof (NautilusDesktopCanvasViewDetails));
}
@@ -561,6 +564,29 @@ const GActionEntry desktop_view_entries[] = {
{ "unstretch", action_unstretch },
};
+static gboolean
+real_special_link_in_selection (NautilusFilesView *view,
+ GList *selection)
+{
+ gboolean saw_link;
+ GList *node;
+ NautilusFile *file;
+
+ saw_link = FALSE;
+
+ for (node = selection; node != NULL; node = node->next) {
+ file = NAUTILUS_FILE (node->data);
+
+ saw_link = NAUTILUS_IS_DESKTOP_ICON_FILE (file);
+
+ if (saw_link) {
+ break;
+ }
+ }
+
+ return saw_link;
+}
+
/* Do nothing */
static void
real_check_empty_states (NautilusFilesView *view)
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index feab55e..8449567 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4056,33 +4056,19 @@ offset_drop_points (GArray *relative_item_points,
}
}
-/* special_link_in_selection
- *
- * Return TRUE if one of our special links is in the selection.
- * Special links include the following:
- * NAUTILUS_DESKTOP_LINK_TRASH, NAUTILUS_DESKTOP_LINK_HOME, NAUTILUS_DESKTOP_LINK_MOUNT
- */
-
static gboolean
-special_link_in_selection (GList *selection)
+nautilus_files_view_special_link_in_selection (NautilusFilesView *view,
+ GList *selection)
{
- gboolean saw_link;
- GList *node;
- NautilusFile *file;
-
- saw_link = FALSE;
-
- for (node = selection; node != NULL; node = node->next) {
- file = NAUTILUS_FILE (node->data);
-
- saw_link = NAUTILUS_IS_DESKTOP_ICON_FILE (file);
-
- if (saw_link) {
- break;
- }
- }
+ return NAUTILUS_FILES_VIEW_CLASS (G_OBJECT_GET_CLASS (view))->special_link_in_selection (view,
selection);
+}
- return saw_link;
+/* Normal view doesn't have any special link */
+static gboolean
+real_special_link_in_selection (NautilusFilesView *view,
+ GList *selection)
+{
+ return FALSE;
}
/* desktop_or_home_dir_in_selection
@@ -6247,7 +6233,7 @@ real_update_actions_state (NautilusFilesView *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_special_link = nautilus_files_view_special_link_in_selection (view, 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_view_is_searching (NAUTILUS_VIEW (view));
@@ -7993,6 +7979,7 @@ nautilus_files_view_class_init (NautilusFilesViewClass *klass)
klass->update_context_menus = real_update_context_menus;
klass->update_actions_state = real_update_actions_state;
klass->check_empty_states = real_check_empty_states;
+ klass->special_link_in_selection = real_special_link_in_selection;
copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE);
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index 2881b31..5ac6583 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -263,6 +263,12 @@ struct NautilusFilesViewClass {
/* Use this to show an optional visual feedback when the directory is empty.
* By default it shows a widget overlay on top of the view */
void (* check_empty_states) (NautilusFilesView *view);
+
+ /* Use this to tell the view whether inside the selection there is some link
+ * that cannot be work with. This is used by the desktop for the trash,
+ * home and other special links. */
+ gboolean (* special_link_in_selection) (NautilusFilesView *view,
+ GList *selection);
};
/* GObject support */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]