[gnome-builder] document: use G_DECLARE_INTERFACE()



commit 706415271fdb977d82894393a4bb3e2d98121f87
Author: Christian Hergert <christian hergert me>
Date:   Sat May 9 16:08:53 2015 -0700

    document: use G_DECLARE_INTERFACE()

 src/documents/gb-document.c |   38 ++++++++++++++++++--------------------
 src/documents/gb-document.h |   12 ++----------
 2 files changed, 20 insertions(+), 30 deletions(-)
---
diff --git a/src/documents/gb-document.c b/src/documents/gb-document.c
index 4abccda..e5e72dd 100644
--- a/src/documents/gb-document.c
+++ b/src/documents/gb-document.c
@@ -46,8 +46,8 @@ gb_document_is_untitled (GbDocument *document)
 {
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->is_untitled)
-    return GB_DOCUMENT_GET_INTERFACE (document)->is_untitled (document);
+  if (GB_DOCUMENT_GET_IFACE (document)->is_untitled)
+    return GB_DOCUMENT_GET_IFACE (document)->is_untitled (document);
   return FALSE;
 }
 
@@ -58,8 +58,8 @@ gb_document_get_mtime (GbDocument *document,
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
   g_return_val_if_fail (mtime, FALSE);
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->get_mtime)
-    return GB_DOCUMENT_GET_INTERFACE (document)->get_mtime (document, mtime);
+  if (GB_DOCUMENT_GET_IFACE (document)->get_mtime)
+    return GB_DOCUMENT_GET_IFACE (document)->get_mtime (document, mtime);
   return FALSE;
 }
 
@@ -83,7 +83,7 @@ gb_document_get_modified (GbDocument *document)
 {
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
 
-  return GB_DOCUMENT_GET_INTERFACE (document)->get_modified (document);
+  return GB_DOCUMENT_GET_IFACE (document)->get_modified (document);
 }
 
 gboolean
@@ -91,8 +91,8 @@ gb_document_get_read_only (GbDocument *document)
 {
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->get_read_only)
-    return GB_DOCUMENT_GET_INTERFACE (document)->get_read_only (document);
+  if (GB_DOCUMENT_GET_IFACE (document)->get_read_only)
+    return GB_DOCUMENT_GET_IFACE (document)->get_read_only (document);
   return FALSE;
 }
 
@@ -101,7 +101,7 @@ gb_document_get_title (GbDocument *document)
 {
   g_return_val_if_fail (GB_IS_DOCUMENT (document), NULL);
 
-  return GB_DOCUMENT_GET_INTERFACE (document)->get_title (document);
+  return GB_DOCUMENT_GET_IFACE (document)->get_title (document);
 }
 
 GtkWidget *
@@ -131,9 +131,9 @@ gb_document_save_async (GbDocument          *document,
   g_return_if_fail (!toplevel || GTK_IS_WIDGET (toplevel));
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->save_async)
-    GB_DOCUMENT_GET_INTERFACE (document)->
-      save_async (document, toplevel, cancellable, callback, user_data);
+  if (GB_DOCUMENT_GET_IFACE (document)->save_async)
+    GB_DOCUMENT_GET_IFACE (document)->save_async (document, toplevel,
+                                                  cancellable, callback, user_data);
 }
 
 gboolean
@@ -144,9 +144,8 @@ gb_document_save_finish (GbDocument    *document,
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->save_finish)
-    return GB_DOCUMENT_GET_INTERFACE (document)->
-      save_finish (document, result, error);
+  if (GB_DOCUMENT_GET_IFACE (document)->save_finish)
+    return GB_DOCUMENT_GET_IFACE (document)->save_finish (document, result, error);
 
   return TRUE;
 }
@@ -162,9 +161,9 @@ gb_document_save_as_async (GbDocument          *document,
   g_return_if_fail (GTK_IS_WIDGET (toplevel));
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->save_as_async)
-    GB_DOCUMENT_GET_INTERFACE (document)->
-      save_as_async (document, toplevel, cancellable, callback, user_data);
+  if (GB_DOCUMENT_GET_IFACE (document)->save_as_async)
+    GB_DOCUMENT_GET_IFACE (document)->save_as_async (document, toplevel,
+                                                     cancellable, callback, user_data);
 }
 
 gboolean
@@ -175,9 +174,8 @@ gb_document_save_as_finish (GbDocument    *document,
   g_return_val_if_fail (GB_IS_DOCUMENT (document), FALSE);
   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
 
-  if (GB_DOCUMENT_GET_INTERFACE (document)->save_as_finish)
-    return GB_DOCUMENT_GET_INTERFACE (document)->
-      save_as_finish (document, result, error);
+  if (GB_DOCUMENT_GET_IFACE (document)->save_as_finish)
+    return GB_DOCUMENT_GET_IFACE (document)->save_as_finish (document, result, error);
 
   return TRUE;
 }
diff --git a/src/documents/gb-document.h b/src/documents/gb-document.h
index bc848df..a639d9a 100644
--- a/src/documents/gb-document.h
+++ b/src/documents/gb-document.h
@@ -23,15 +23,9 @@
 
 G_BEGIN_DECLS
 
-#define GB_TYPE_DOCUMENT               (gb_document_get_type ())
-#define GB_DOCUMENT(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GB_TYPE_DOCUMENT, GbDocument))
-#define GB_IS_DOCUMENT(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GB_TYPE_DOCUMENT))
-#define GB_DOCUMENT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GB_TYPE_DOCUMENT, 
GbDocumentInterface))
+#define GB_TYPE_DOCUMENT (gb_document_get_type ())
 
-typedef struct _GbDocument          GbDocument;
-typedef struct _GbDocumentInterface GbDocumentInterface;
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (GbDocument, g_object_unref)
+G_DECLARE_INTERFACE (GbDocument, gb_document, GB, DOCUMENT, GObject)
 
 struct _GbDocumentInterface
 {
@@ -68,7 +62,6 @@ gboolean     gb_document_get_mtime      (GbDocument           *document,
                                          GTimeVal             *mtime);
 gboolean     gb_document_get_read_only  (GbDocument           *document);
 const gchar *gb_document_get_title      (GbDocument           *document);
-GType        gb_document_get_type       (void);
 gboolean     gb_document_is_untitled    (GbDocument           *document);
 void         gb_document_save_async     (GbDocument           *document,
                                          GtkWidget            *toplevel,
@@ -87,7 +80,6 @@ gboolean     gb_document_save_as_finish (GbDocument           *document,
                                          GAsyncResult         *result,
                                          GError              **error);
 
-
 G_END_DECLS
 
 #endif /* GB_DOCUMENT_H */


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