[gtksourceview/wip/loader-saver] Make GtkSourceMountOperationFactory introspection friendly



commit 14e8308436c800d2fff58964b6111a6b426a0527
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Jun 11 00:24:59 2014 +0200

    Make GtkSourceMountOperationFactory introspection friendly
    
    There was a GI warning.

 gtksourceview/gtksourcefile.c  |   26 +++++++++++++++++++++-----
 gtksourceview/gtksourcefile.h  |   16 +++++++++++++++-
 gtksourceview/gtksourcetypes.h |   11 -----------
 3 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index ae3929b..8cd0155 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -65,6 +65,7 @@ struct _GtkSourceFilePrivate
 
        GtkSourceMountOperationFactory mount_operation_factory;
        gpointer mount_operation_userdata;
+       GDestroyNotify mount_operation_notify;
 
        /* Last known modification time of 'location'. The value is updated on a
         * file loading or file saving.
@@ -158,6 +159,12 @@ gtk_source_file_dispose (GObject *object)
 
        g_clear_object (&file->priv->location);
 
+       if (file->priv->mount_operation_notify != NULL)
+       {
+               file->priv->mount_operation_notify (file->priv->mount_operation_userdata);
+               file->priv->mount_operation_notify = NULL;
+       }
+
        G_OBJECT_CLASS (gtk_source_file_parent_class)->dispose (object);
 }
 
@@ -420,9 +427,11 @@ gtk_source_file_get_compression_type (GtkSourceFile *file)
 /**
  * gtk_source_file_set_mount_operation_factory:
  * @file: a #GtkSourceFile.
- * @callback: a #GtkSourceMountOperationFactory to call when a #GMountOperation
- *   is needed.
- * @user_data: the data to pass to the @callback function.
+ * @callback: (scope notified): a #GtkSourceMountOperationFactory to call when a
+ *   #GMountOperation is needed.
+ * @user_data: (closure): the data to pass to the @callback function.
+ * @notify: (nullable): function to call on @user_data when the @callback is no
+ *   longer needed, or %NULL.
  *
  * Sets a #GtkSourceMountOperationFactory function that will be called when a
  * #GMountOperation must be created. This is useful for creating a
@@ -436,19 +445,26 @@ gtk_source_file_get_compression_type (GtkSourceFile *file)
 void
 gtk_source_file_set_mount_operation_factory (GtkSourceFile                  *file,
                                             GtkSourceMountOperationFactory  callback,
-                                            gpointer                        user_data)
+                                            gpointer                        user_data,
+                                            GDestroyNotify                  notify)
 {
        g_return_if_fail (GTK_SOURCE_IS_FILE (file));
 
+       if (file->priv->mount_operation_notify != NULL)
+       {
+               file->priv->mount_operation_notify (file->priv->mount_operation_userdata);
+       }
+
        file->priv->mount_operation_factory = callback;
        file->priv->mount_operation_userdata = user_data;
+       file->priv->mount_operation_notify = notify;
 }
 
 GMountOperation *
 _gtk_source_file_create_mount_operation (GtkSourceFile *file)
 {
        return (file != NULL && file->priv->mount_operation_factory != NULL) ?
-               file->priv->mount_operation_factory (file->priv->mount_operation_userdata) :
+               file->priv->mount_operation_factory (file, file->priv->mount_operation_userdata) :
                g_mount_operation_new ();
 }
 
diff --git a/gtksourceview/gtksourcefile.h b/gtksourceview/gtksourcefile.h
index 912cf47..fcae301 100644
--- a/gtksourceview/gtksourcefile.h
+++ b/gtksourceview/gtksourcefile.h
@@ -37,6 +37,19 @@ G_BEGIN_DECLS
 typedef struct _GtkSourceFileClass    GtkSourceFileClass;
 typedef struct _GtkSourceFilePrivate  GtkSourceFilePrivate;
 
+/**
+ * GtkSourceMountOperationFactory:
+ * @file: a #GtkSourceFile.
+ * @userdata: user data
+ *
+ * Type definition for a function that will be called to create a
+ * #GMountOperation. This is useful for creating a #GtkMountOperation.
+ *
+ * Since: 3.14
+ */
+typedef GMountOperation *(*GtkSourceMountOperationFactory) (GtkSourceFile *file,
+                                                           gpointer       userdata);
+
 struct _GtkSourceFile
 {
        GObject parent;
@@ -68,7 +81,8 @@ GtkSourceCompressionType
 
 void            gtk_source_file_set_mount_operation_factory    (GtkSourceFile                  *file,
                                                                 GtkSourceMountOperationFactory  callback,
-                                                                gpointer                        user_data);
+                                                                gpointer                        user_data,
+                                                                GDestroyNotify                  notify);
 
 G_GNUC_INTERNAL
 void            _gtk_source_file_set_location                  (GtkSourceFile *file,
diff --git a/gtksourceview/gtksourcetypes.h b/gtksourceview/gtksourcetypes.h
index c2bfa87..5c1af72 100644
--- a/gtksourceview/gtksourcetypes.h
+++ b/gtksourceview/gtksourcetypes.h
@@ -96,17 +96,6 @@ typedef enum
        GTK_SOURCE_COMPRESSION_TYPE_GZIP
 } GtkSourceCompressionType;
 
-/**
- * GtkSourceMountOperationFactory:
- * @userdata: user data
- *
- * Type definition for a function that will be called to create a
- * #GMountOperation. This is useful for creating a #GtkMountOperation.
- *
- * Since: 3.14
- */
-typedef GMountOperation *(*GtkSourceMountOperationFactory)(gpointer userdata);
-
 G_END_DECLS
 
 #endif /* __GTK_SOURCE_TYPES_H__ */


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