[evince] [shell] Use G_DEFINE_INTERFACE and remove our own macro



commit d76bef42ca0d292a7a04d61663d4da7536136479
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Fri May 7 13:19:56 2010 +0200

    [shell] Use G_DEFINE_INTERFACE and remove our own macro

 libdocument/ev-document.h      |   31 -------------------------------
 shell/ev-sidebar-attachments.c |    4 ++--
 shell/ev-sidebar-layers.c      |    8 ++++----
 shell/ev-sidebar-links.c       |    4 ++--
 shell/ev-sidebar-page.c        |   10 +++++-----
 shell/ev-sidebar-page.h        |   10 +++++-----
 shell/ev-sidebar-thumbnails.c  |   18 +++++++++---------
 7 files changed, 27 insertions(+), 58 deletions(-)
---
diff --git a/libdocument/ev-document.h b/libdocument/ev-document.h
index 09c97aa..1064f16 100644
--- a/libdocument/ev-document.h
+++ b/libdocument/ev-document.h
@@ -271,37 +271,6 @@ type_name##_get_type (void)
 	return g_define_type_id__volatile;                                            \
 }
 
-/* A convenience macro for GTypeInterface definitions, which declares
- * a default vtable initialization function and defines a *_get_type()
- * function.
- *
- * The macro expects the interface initialization function to have the
- * name <literal>t_n ## _default_init</literal>, and the interface
- * structure to have the name <literal>TN ## Interface</literal>.
- */
-#define EV_DEFINE_INTERFACE(TypeName, type_name, TYPE_PREREQ)	                             \
-static void     type_name##_class_init        (TypeName##Iface *klass);                      \
-                                                                                             \
-GType                                                                                        \
-type_name##_get_type (void)                                                                  \
-{                                                                                            \
-        static volatile gsize g_define_type_id__volatile = 0;                                \
-	if (g_once_init_enter (&g_define_type_id__volatile)) {                               \
-		GType g_define_type_id =                                                     \
-		    g_type_register_static_simple (G_TYPE_INTERFACE,                         \
-		                                   g_intern_static_string (#TypeName),       \
-		                                   sizeof (TypeName##Iface),                 \
-		                                   (GClassInitFunc)type_name##_class_init,   \
-		                                   0,                                        \
-		                                   (GInstanceInitFunc)NULL,                  \
-						   (GTypeFlags) 0);                          \
-		if (TYPE_PREREQ)                                                             \
-			g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ);   \
-		g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);           \
-	}                                                                                    \
-	return g_define_type_id__volatile;                                                   \
-}
-
 /*
  * A convenience macro for boxed type implementations, which defines a
  * type_name_get_type() function registering the boxed type.
diff --git a/shell/ev-sidebar-attachments.c b/shell/ev-sidebar-attachments.c
index 0b1aa8d..3d2cce2 100644
--- a/shell/ev-sidebar-attachments.c
+++ b/shell/ev-sidebar-attachments.c
@@ -67,7 +67,7 @@ struct _EvSidebarAttachmentsPrivate {
 	GHashTable     *icon_cache;
 };
 
-static void ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface);
+static void ev_sidebar_attachments_page_iface_init (EvSidebarPageInterface *iface);
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarAttachments,
                         ev_sidebar_attachments,
@@ -698,7 +698,7 @@ ev_sidebar_attachments_get_label (EvSidebarPage *sidebar_page)
 }
 
 static void
-ev_sidebar_attachments_page_iface_init (EvSidebarPageIface *iface)
+ev_sidebar_attachments_page_iface_init (EvSidebarPageInterface *iface)
 {
 	iface->support_document = ev_sidebar_attachments_support_document;
 	iface->set_model = ev_sidebar_attachments_set_model;
diff --git a/shell/ev-sidebar-layers.c b/shell/ev-sidebar-layers.c
index 0095c14..938f457 100644
--- a/shell/ev-sidebar-layers.c
+++ b/shell/ev-sidebar-layers.c
@@ -47,9 +47,9 @@ enum {
 	N_SIGNALS
 };
 
-static void ev_sidebar_layers_page_iface_init (EvSidebarPageIface *iface);
-static void job_finished_callback             (EvJobLayers        *job,
-					       EvSidebarLayers    *sidebar_layers);
+static void ev_sidebar_layers_page_iface_init (EvSidebarPageInterface *iface);
+static void job_finished_callback             (EvJobLayers            *job,
+					       EvSidebarLayers        *sidebar_layers);
 
 static guint signals[N_SIGNALS];
 
@@ -402,7 +402,7 @@ ev_sidebar_layers_get_label (EvSidebarPage *sidebar_page)
 }
 
 static void
-ev_sidebar_layers_page_iface_init (EvSidebarPageIface *iface)
+ev_sidebar_layers_page_iface_init (EvSidebarPageInterface *iface)
 {
 	iface->support_document = ev_sidebar_layers_support_document;
 	iface->set_model = ev_sidebar_layers_set_model;
diff --git a/shell/ev-sidebar-links.c b/shell/ev-sidebar-links.c
index 335913a..0d0ece8 100644
--- a/shell/ev-sidebar-links.c
+++ b/shell/ev-sidebar-links.c
@@ -73,7 +73,7 @@ static void job_finished_callback 			(EvJobLinks     *job,
 				    		         EvSidebarLinks *sidebar_links);
 static void ev_sidebar_links_set_current_page           (EvSidebarLinks *sidebar_links,
 							 gint            current_page);
-static void ev_sidebar_links_page_iface_init 		(EvSidebarPageIface *iface);
+static void ev_sidebar_links_page_iface_init 		(EvSidebarPageInterface *iface);
 static gboolean ev_sidebar_links_support_document	(EvSidebarPage  *sidebar_page,
 						         EvDocument     *document);
 static const gchar* ev_sidebar_links_get_label 		(EvSidebarPage *sidebar_page);
@@ -751,7 +751,7 @@ ev_sidebar_links_get_label (EvSidebarPage *sidebar_page)
 }
 
 static void
-ev_sidebar_links_page_iface_init (EvSidebarPageIface *iface)
+ev_sidebar_links_page_iface_init (EvSidebarPageInterface *iface)
 {
 	iface->support_document = ev_sidebar_links_support_document;
 	iface->set_model = ev_sidebar_links_set_model;
diff --git a/shell/ev-sidebar-page.c b/shell/ev-sidebar-page.c
index 78e1a7f..fdb8d4a 100644
--- a/shell/ev-sidebar-page.c
+++ b/shell/ev-sidebar-page.c
@@ -26,13 +26,13 @@
 
 #include "ev-sidebar-page.h"
 
-EV_DEFINE_INTERFACE (EvSidebarPage, ev_sidebar_page, 0)
+G_DEFINE_INTERFACE (EvSidebarPage, ev_sidebar_page, 0)
 
 gboolean 
 ev_sidebar_page_support_document (EvSidebarPage *sidebar_page,
 				  EvDocument    *document)
 {
-        EvSidebarPageIface *iface;
+        EvSidebarPageInterface *iface;
 
 	g_return_val_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page), FALSE);
         g_return_val_if_fail (EV_IS_DOCUMENT (document), FALSE);
@@ -48,7 +48,7 @@ void
 ev_sidebar_page_set_model (EvSidebarPage   *sidebar_page,
 			   EvDocumentModel *model)
 {
-	EvSidebarPageIface *iface;
+	EvSidebarPageInterface *iface;
 
         g_return_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page));
 	g_return_if_fail (EV_IS_DOCUMENT_MODEL (model));
@@ -63,7 +63,7 @@ ev_sidebar_page_set_model (EvSidebarPage   *sidebar_page,
 const gchar *
 ev_sidebar_page_get_label (EvSidebarPage *sidebar_page)
 {
-	EvSidebarPageIface *iface;
+	EvSidebarPageInterface *iface;
 
         g_return_val_if_fail (EV_IS_SIDEBAR_PAGE (sidebar_page), NULL);
 
@@ -76,7 +76,7 @@ ev_sidebar_page_get_label (EvSidebarPage *sidebar_page)
 
 
 static void
-ev_sidebar_page_class_init (EvSidebarPageIface *iface)
+ev_sidebar_page_default_init (EvSidebarPageInterface *iface)
 {
 	static gboolean initialized = FALSE;
  
diff --git a/shell/ev-sidebar-page.h b/shell/ev-sidebar-page.h
index 5cd6fec..21ef92c 100644
--- a/shell/ev-sidebar-page.h
+++ b/shell/ev-sidebar-page.h
@@ -31,15 +31,15 @@ G_BEGIN_DECLS
 
 #define EV_TYPE_SIDEBAR_PAGE	    	(ev_sidebar_page_get_type ())
 #define EV_SIDEBAR_PAGE(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EV_TYPE_SIDEBAR_PAGE, EvSidebarPage))
-#define EV_SIDEBAR_PAGE_IFACE(k)	(G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageIface))
+#define EV_SIDEBAR_PAGE_IFACE(k)	(G_TYPE_CHECK_CLASS_CAST((k), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageInterface))
 #define EV_IS_SIDEBAR_PAGE(o)	    	(G_TYPE_CHECK_INSTANCE_TYPE ((o), EV_TYPE_SIDEBAR_PAGE))
 #define EV_IS_SIDEBAR_PAGE_IFACE(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EV_TYPE_SIDEBAR_PAGE))
-#define EV_SIDEBAR_PAGE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageIface))
+#define EV_SIDEBAR_PAGE_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EV_TYPE_SIDEBAR_PAGE, EvSidebarPageInterface))
 
-typedef struct _EvSidebarPage	  EvSidebarPage;
-typedef struct _EvSidebarPageIface   EvSidebarPageIface;
+typedef struct _EvSidebarPage	         EvSidebarPage;
+typedef struct _EvSidebarPageInterface   EvSidebarPageInterface;
 
-struct _EvSidebarPageIface
+struct _EvSidebarPageInterface
 {
 	GTypeInterface base_iface;
 
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index 7b593f3..4aaeeba 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -91,14 +91,14 @@ enum {
 	PROP_WIDGET,
 };
 
-static void         ev_sidebar_thumbnails_clear_model      (EvSidebarThumbnails *sidebar);
-static gboolean     ev_sidebar_thumbnails_support_document (EvSidebarPage       *sidebar_page,
-							    EvDocument          *document);
-static void         ev_sidebar_thumbnails_page_iface_init  (EvSidebarPageIface  *iface);
-static const gchar* ev_sidebar_thumbnails_get_label        (EvSidebarPage       *sidebar_page);
-static void         thumbnail_job_completed_callback       (EvJobThumbnail      *job,
-							    EvSidebarThumbnails *sidebar_thumbnails);
-static void         adjustment_changed_cb                  (EvSidebarThumbnails *sidebar_thumbnails);
+static void         ev_sidebar_thumbnails_clear_model      (EvSidebarThumbnails     *sidebar);
+static gboolean     ev_sidebar_thumbnails_support_document (EvSidebarPage           *sidebar_page,
+							    EvDocument              *document);
+static void         ev_sidebar_thumbnails_page_iface_init  (EvSidebarPageInterface  *iface);
+static const gchar* ev_sidebar_thumbnails_get_label        (EvSidebarPage           *sidebar_page);
+static void         thumbnail_job_completed_callback       (EvJobThumbnail          *job,
+							    EvSidebarThumbnails     *sidebar_thumbnails);
+static void         adjustment_changed_cb                  (EvSidebarThumbnails     *sidebar_thumbnails);
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarThumbnails, 
                         ev_sidebar_thumbnails, 
@@ -966,7 +966,7 @@ ev_sidebar_thumbnails_get_label (EvSidebarPage *sidebar_page)
 }
 
 static void
-ev_sidebar_thumbnails_page_iface_init (EvSidebarPageIface *iface)
+ev_sidebar_thumbnails_page_iface_init (EvSidebarPageInterface *iface)
 {
 	iface->support_document = ev_sidebar_thumbnails_support_document;
 	iface->set_model = ev_sidebar_thumbnails_set_model;



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