[nautilus/wip/csoriano/destktop-split2: 32/60] directory: allow overriding the creation of files



commit 0a2a4088aab2b56f76d7905dcf10f5f2be248ff1
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Mar 29 21:47:11 2016 +0200

    directory: allow overriding the creation of files
    
    So subclasses like the desktop directory can do their own.

 libnautilus-private/nautilus-directory.c |   15 +++++++++++++++
 libnautilus-private/nautilus-directory.h |    6 ++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index a79fe30..06cb6a7 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -65,6 +65,9 @@ static GList *            real_get_file_list                  (NautilusDirectory
 static gboolean                  real_is_editable                    (NautilusDirectory      *directory);
 static void               set_directory_location              (NautilusDirectory      *directory,
                                                               GFile                  *location);
+static NautilusFile *     real_new_file_from_filename (NautilusDirectory *directory,
+                                                       const char        *filename,
+                                                       gboolean           self_owned);
 
 G_DEFINE_TYPE (NautilusDirectory, nautilus_directory, G_TYPE_OBJECT);
 
@@ -111,6 +114,8 @@ nautilus_directory_class_init (NautilusDirectoryClass *klass)
 
        object_class = G_OBJECT_CLASS (klass);
        
+        klass->new_file_from_filename = real_new_file_from_filename;
+
        object_class->finalize = nautilus_directory_finalize;
        object_class->set_property = nautilus_directory_set_property;
        object_class->get_property = nautilus_directory_get_property;
@@ -547,6 +552,16 @@ nautilus_directory_new_file_from_filename (NautilusDirectory *directory,
                                            const char        *filename,
                                            gboolean           self_owned)
 {
+        return NAUTILUS_DIRECTORY_CLASS (G_OBJECT_GET_CLASS (directory))->new_file_from_filename (directory,
+                                                                                                  filename,
+                                                                                                  
self_owned);
+}
+
+static NautilusFile *
+real_new_file_from_filename (NautilusDirectory *directory,
+                             const char        *filename,
+                             gboolean           self_owned)
+{
        NautilusFile *file;
 
        g_assert (NAUTILUS_IS_DIRECTORY (directory));
diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h
index 46a253c..de3c0d9 100644
--- a/libnautilus-private/nautilus-directory.h
+++ b/libnautilus-private/nautilus-directory.h
@@ -137,6 +137,12 @@ typedef struct
         * An example of this is the search directory.
         */
        gboolean (* is_editable)         (NautilusDirectory *directory);
+
+        /* Subclasses can use this to create custom files when asked by the user
+         * or the nautilus cache. */
+        NautilusFile * (* new_file_from_filename) (NautilusDirectory *directory,
+                                                   const char        *filename,
+                                                   gboolean           self_owned);
 } NautilusDirectoryClass;
 
 /* Basic GObject requirements. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]