[nautilus/wip/csoriano/destktop-split2] mime-actions: move opens_in_view to file



commit 9df13f5c9e7a4ebb8628f490958664866c464911
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 48dc347..4032d0c 100644
--- a/libnautilus-private/nautilus-desktop-icon-file.c
+++ b/libnautilus-private/nautilus-desktop-icon-file.c
@@ -464,6 +464,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,
@@ -509,6 +515,7 @@ nautilus_desktop_icon_file_class_init (NautilusDesktopIconFileClass *klass)
         file_class->get_drop_target_uri = real_get_drop_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 0bf410d..4b9548d 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -1613,6 +1613,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,
@@ -8006,6 +8019,7 @@ nautilus_file_class_init (NautilusFileClass *class)
        class->get_drop_target_uri = real_get_drop_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 e9e73de..e25cdf4 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -457,6 +457,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);
 
@@ -605,6 +607,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 215e8e8..95cc880 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -42,7 +42,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>
 
@@ -673,13 +672,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)
 {
@@ -711,7 +703,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 f1439e0..1eeb4c2 100644
--- a/src/nautilus-mime-actions.h
+++ b/src/nautilus-mime-actions.h
@@ -38,7 +38,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]