[nautilus/wip/csoriano/desktop-split: 42/53] mime-actions: move opens_in_view to file
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/desktop-split: 42/53] mime-actions: move opens_in_view to file
- Date: Wed, 6 Apr 2016 09:08:07 +0000 (UTC)
commit 80f6591658c3247e81cdfab93acd9708a441137e
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Mar 31 00:20:11 2016 +0200
mime-actions: move opens_in_view to file
And allow overriding of subclasses.
Nautilus mime actions file currently uses the file as parameter, as if
it was part of the nautilus file class.
However it's hosted in a different file, even though we need to special
case some subclasses of nautilus file for its management.
imho, this code design is wrong, since it defeats the purpose of OOP.
So move it to the nautilus file, allow overriding, and override this
vfunc in the subclasses that need it, like the desktop-icon.
libnautilus-private/nautilus-desktop-icon-file.c | 7 +++++++
libnautilus-private/nautilus-file.c | 14 ++++++++++++++
libnautilus-private/nautilus-file.h | 4 ++++
src/nautilus-files-view.c | 4 ++--
src/nautilus-mime-actions.c | 10 +---------
src/nautilus-mime-actions.h | 1 -
6 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/libnautilus-private/nautilus-desktop-icon-file.c
b/libnautilus-private/nautilus-desktop-icon-file.c
index 2dc10b8..48b06d1 100644
--- a/libnautilus-private/nautilus-desktop-icon-file.c
+++ b/libnautilus-private/nautilus-desktop-icon-file.c
@@ -462,6 +462,12 @@ real_invalidate_attributes_internal (NautilusFile *file)
return;
}
+static gboolean
+real_opens_in_view (NautilusFile *file)
+{
+ return TRUE;
+}
+
static void
nautilus_desktop_icon_file_set_metadata (NautilusFile *file,
const char *key,
@@ -507,6 +513,7 @@ nautilus_desktop_icon_file_class_init (NautilusDesktopIconFileClass *klass)
file_class->get_target_uri = real_get_target_uri;
file_class->drag_can_accept_files = real_drag_can_accept_files;
file_class->invalidate_attributes_internal = real_invalidate_attributes_internal;
+ file_class->opens_in_view = real_opens_in_view;
g_type_class_add_private (object_class, sizeof(NautilusDesktopIconFileDetails));
}
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 2baf939..51cc87c 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -1612,6 +1612,19 @@ nautilus_file_get_uri_scheme (NautilusFile *file)
return scheme;
}
+
+gboolean
+nautilus_file_opens_in_view (NautilusFile *file)
+{
+ return NAUTILUS_FILE_CLASS (G_OBJECT_GET_CLASS (file))->opens_in_view (file);
+}
+
+static gboolean
+real_opens_in_view (NautilusFile *file)
+{
+ return nautilus_file_is_directory (file);
+}
+
NautilusFileOperation *
nautilus_file_operation_new (NautilusFile *file,
NautilusFileOperationCallback callback,
@@ -8005,6 +8018,7 @@ nautilus_file_class_init (NautilusFileClass *class)
class->get_target_uri = real_get_target_uri;
class->drag_can_accept_files = real_drag_can_accept_files;
class->invalidate_attributes_internal = real_invalidate_attributes_internal;
+ class->opens_in_view = real_opens_in_view;
signals[CHANGED] =
g_signal_new ("changed",
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index a6e265b..ca97c75 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -456,6 +456,8 @@ GdkPixbuf * nautilus_file_get_icon_pixbuf (Nautilu
int
scale,
NautilusFileIconFlags
flags);
+/* Whether the file should open inside a view */
+gboolean nautilus_file_opens_in_view (NautilusFile
*file);
/* Thumbnailing handling */
gboolean nautilus_file_is_thumbnailing (NautilusFile
*file);
@@ -604,6 +606,8 @@ typedef struct {
void (* invalidate_attributes_internal) (NautilusFile *file,
NautilusFileAttributes file_attributes);
+
+ gboolean (* opens_in_view) (NautilusFile *file);
} NautilusFileClass;
#endif /* NAUTILUS_FILE_H */
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 4eb136e..37ca728 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -6299,7 +6299,7 @@ real_update_actions_state (NautilusFilesView *view)
file = NAUTILUS_FILE (selection->data);
- if (!nautilus_mime_file_opens_in_view (file)) {
+ if (!nautilus_file_opens_in_view (file)) {
item_opens_in_view = FALSE;
}
@@ -6586,7 +6586,7 @@ update_selection_menu (NautilusFilesView *view)
show_run = FALSE;
}
- if (!nautilus_mime_file_opens_in_view (file)) {
+ if (!nautilus_file_opens_in_view (file)) {
item_opens_in_view = FALSE;
}
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index a0b25e7..b132544 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -41,7 +41,6 @@
#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-program-choosing.h>
-#include <libnautilus-private/nautilus-desktop-icon-file.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-signaller.h>
@@ -672,13 +671,6 @@ get_default_executable_text_file_action (void)
}
}
-gboolean
-nautilus_mime_file_opens_in_view (NautilusFile *file)
-{
- return (nautilus_file_is_directory (file) ||
- NAUTILUS_IS_DESKTOP_ICON_FILE (file));
-}
-
static ActivationAction
get_activation_action (NautilusFile *file)
{
@@ -710,7 +702,7 @@ get_activation_action (NautilusFile *file)
}
if (action == ACTIVATION_ACTION_DO_NOTHING) {
- if (nautilus_mime_file_opens_in_view (file)) {
+ if (nautilus_file_opens_in_view (file)) {
action = ACTIVATION_ACTION_OPEN_IN_VIEW;
} else {
action = ACTIVATION_ACTION_OPEN_IN_APPLICATION;
diff --git a/src/nautilus-mime-actions.h b/src/nautilus-mime-actions.h
index 72c782a..0349c21 100644
--- a/src/nautilus-mime-actions.h
+++ b/src/nautilus-mime-actions.h
@@ -37,7 +37,6 @@ GList * nautilus_mime_get_applications_for_file (Nauti
GAppInfo * nautilus_mime_get_default_application_for_files (GList *files);
-gboolean nautilus_mime_file_opens_in_view (NautilusFile *file);
gboolean nautilus_mime_file_opens_in_external_app (NautilusFile *file);
gboolean nautilus_mime_file_launches (NautilusFile *file);
void nautilus_mime_activate_files (GtkWindow
*parent_window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]