[gtksourceview/wip/chergert/gsv-gtk4: 64/175] completion: use G_DEFINE_INTERFACE



commit d76ab15ad17391ef0e7a9d02520a8d95f5bb95a9
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 9 15:01:42 2020 -0800

    completion: use G_DEFINE_INTERFACE

 .../words/gtksourcecompletionwords.c               |   4 +-
 gtksourceview/gtksourcecompletionprovider.c        |  38 +++---
 gtksourceview/gtksourcecompletionprovider.h        | 128 ++++++++-------------
 tests/test-completion.c                            |   4 +-
 testsuite/test-completion-model.c                  |   4 +-
 5 files changed, 72 insertions(+), 106 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index 4bb5e91d..32b04e46 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -92,7 +92,7 @@ typedef struct
 
 static GParamSpec *properties[N_PROPERTIES];
 
-static void gtk_source_completion_words_iface_init (GtkSourceCompletionProviderIface *iface);
+static void gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionWords,
                         gtk_source_completion_words,
@@ -572,7 +572,7 @@ gtk_source_completion_words_get_activation (GtkSourceCompletionProvider *provide
 }
 
 static void
-gtk_source_completion_words_iface_init (GtkSourceCompletionProviderIface *iface)
+gtk_source_completion_words_iface_init (GtkSourceCompletionProviderInterface *iface)
 {
        iface->get_name = gtk_source_completion_words_get_name;
        iface->get_icon = gtk_source_completion_words_get_icon;
diff --git a/gtksourceview/gtksourcecompletionprovider.c b/gtksourceview/gtksourcecompletionprovider.c
index 9a3302cc..31b26c6a 100644
--- a/gtksourceview/gtksourcecompletionprovider.c
+++ b/gtksourceview/gtksourcecompletionprovider.c
@@ -40,9 +40,7 @@
  * will be used.
  */
 
-typedef GtkSourceCompletionProviderIface GtkSourceCompletionProviderInterface;
-
-G_DEFINE_INTERFACE(GtkSourceCompletionProvider, gtk_source_completion_provider, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (GtkSourceCompletionProvider, gtk_source_completion_provider, G_TYPE_OBJECT)
 
 /* Default implementations */
 static gchar *
@@ -135,7 +133,7 @@ gtk_source_completion_provider_get_priority_default (GtkSourceCompletionProvider
 }
 
 static void
-gtk_source_completion_provider_default_init (GtkSourceCompletionProviderIface *iface)
+gtk_source_completion_provider_default_init (GtkSourceCompletionProviderInterface *iface)
 {
        iface->get_name = gtk_source_completion_provider_get_name_default;
 
@@ -173,7 +171,7 @@ gtk_source_completion_provider_get_name (GtkSourceCompletionProvider *provider)
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), NULL);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_name (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_name (provider);
 }
 
 /**
@@ -190,7 +188,7 @@ gtk_source_completion_provider_get_icon (GtkSourceCompletionProvider *provider)
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), NULL);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_icon (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_icon (provider);
 }
 
 /**
@@ -209,7 +207,7 @@ gtk_source_completion_provider_get_icon_name (GtkSourceCompletionProvider *provi
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), NULL);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_icon_name (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_icon_name (provider);
 }
 
 /**
@@ -228,7 +226,7 @@ gtk_source_completion_provider_get_gicon (GtkSourceCompletionProvider *provider)
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), NULL);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_gicon (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_gicon (provider);
 }
 
 /**
@@ -245,7 +243,7 @@ gtk_source_completion_provider_populate (GtkSourceCompletionProvider *provider,
 {
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider));
 
-       GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->populate (provider, context);
+       GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->populate (provider, context);
 }
 
 /**
@@ -261,7 +259,7 @@ gtk_source_completion_provider_get_activation (GtkSourceCompletionProvider *prov
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), 
GTK_SOURCE_COMPLETION_ACTIVATION_NONE);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_activation (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_activation (provider);
 }
 
 /**
@@ -280,8 +278,7 @@ gtk_source_completion_provider_match (GtkSourceCompletionProvider *provider,
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), TRUE);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->match (provider,
-                                                                              context);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->match (provider, context);
 }
 
 /**
@@ -316,7 +313,7 @@ gtk_source_completion_provider_get_info_widget (GtkSourceCompletionProvider *pro
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), NULL);
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROPOSAL (proposal), NULL);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_info_widget (provider, proposal);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_info_widget (provider, proposal);
 }
 
 /**
@@ -343,7 +340,7 @@ gtk_source_completion_provider_update_info (GtkSourceCompletionProvider *provide
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_PROPOSAL (proposal));
        g_return_if_fail (GTK_SOURCE_IS_COMPLETION_INFO (info));
 
-       GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->update_info (provider, proposal, info);
+       GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->update_info (provider, proposal, info);
 }
 
 /**
@@ -379,10 +376,7 @@ gtk_source_completion_provider_get_start_iter (GtkSourceCompletionProvider *prov
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROPOSAL (proposal), FALSE);
        g_return_val_if_fail (iter != NULL, FALSE);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_start_iter (provider,
-                                                                                       context,
-                                                                                       proposal,
-                                                                                       iter);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_start_iter (provider, context, 
proposal, iter);
 }
 
 /**
@@ -413,9 +407,7 @@ gtk_source_completion_provider_activate_proposal (GtkSourceCompletionProvider *p
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), FALSE);
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROPOSAL (proposal), FALSE);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->activate_proposal (provider,
-                                                                                          proposal,
-                                                                                          iter);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->activate_proposal (provider, proposal, 
iter);
 }
 
 /**
@@ -433,7 +425,7 @@ gtk_source_completion_provider_get_interactive_delay (GtkSourceCompletionProvide
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), -1);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_interactive_delay (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_interactive_delay (provider);
 }
 
 /**
@@ -451,5 +443,5 @@ gtk_source_completion_provider_get_priority (GtkSourceCompletionProvider *provid
 {
        g_return_val_if_fail (GTK_SOURCE_IS_COMPLETION_PROVIDER (provider), 0);
 
-       return GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE (provider)->get_priority (provider);
+       return GTK_SOURCE_COMPLETION_PROVIDER_GET_IFACE (provider)->get_priority (provider);
 }
diff --git a/gtksourceview/gtksourcecompletionprovider.h b/gtksourceview/gtksourcecompletionprovider.h
index b2b53991..4c1c05ad 100644
--- a/gtksourceview/gtksourcecompletionprovider.h
+++ b/gtksourceview/gtksourcecompletionprovider.h
@@ -32,15 +32,13 @@
 
 G_BEGIN_DECLS
 
-#define GTK_SOURCE_TYPE_COMPLETION_PROVIDER                    (gtk_source_completion_provider_get_type ())
-#define GTK_SOURCE_COMPLETION_PROVIDER(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GTK_SOURCE_TYPE_COMPLETION_PROVIDER, GtkSourceCompletionProvider))
-#define GTK_SOURCE_IS_COMPLETION_PROVIDER(obj)                         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_PROVIDER))
-#define GTK_SOURCE_COMPLETION_PROVIDER_GET_INTERFACE(obj)      (G_TYPE_INSTANCE_GET_INTERFACE ((obj), 
GTK_SOURCE_TYPE_COMPLETION_PROVIDER, GtkSourceCompletionProviderIface))
+#define GTK_SOURCE_TYPE_COMPLETION_PROVIDER (gtk_source_completion_provider_get_type())
 
-typedef struct _GtkSourceCompletionProviderIface GtkSourceCompletionProviderIface;
+GTK_SOURCE_AVAILABLE_IN_ALL
+G_DECLARE_INTERFACE (GtkSourceCompletionProvider, gtk_source_completion_provider, GTK_SOURCE, 
COMPLETION_PROVIDER, GObject)
 
 /**
- * GtkSourceCompletionProviderIface:
+ * GtkSourceCompletionProviderInterface:
  * @g_iface: The parent interface.
  * @get_name: The virtual function pointer for gtk_source_completion_provider_get_name().
  * Must be implemented.
@@ -71,94 +69,70 @@ typedef struct _GtkSourceCompletionProviderIface GtkSourceCompletionProviderIfac
  *
  * The virtual function table for #GtkSourceCompletionProvider.
  */
-struct _GtkSourceCompletionProviderIface
+struct _GtkSourceCompletionProviderInterface
 {
        GTypeInterface g_iface;
 
-       gchar           *(*get_name)            (GtkSourceCompletionProvider *provider);
-
-       GdkPixbuf       *(*get_icon)            (GtkSourceCompletionProvider *provider);
-       const gchar     *(*get_icon_name)   (GtkSourceCompletionProvider *provider);
-       GIcon           *(*get_gicon)       (GtkSourceCompletionProvider *provider);
-
-       void             (*populate)            (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionContext  *context);
-
-       gboolean         (*match)               (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionContext  *context);
-
-       GtkSourceCompletionActivation
-                        (*get_activation)      (GtkSourceCompletionProvider *provider);
-
-       GtkWidget       *(*get_info_widget)     (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionProposal *proposal);
-       void             (*update_info)         (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionProposal *proposal,
-                                                GtkSourceCompletionInfo     *info);
-
-       gboolean         (*get_start_iter)      (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionContext  *context,
-                                                GtkSourceCompletionProposal *proposal,
-                                                GtkTextIter                 *iter);
-       gboolean         (*activate_proposal)   (GtkSourceCompletionProvider *provider,
-                                                GtkSourceCompletionProposal *proposal,
-                                                GtkTextIter                 *iter);
-
-       gint             (*get_interactive_delay) (GtkSourceCompletionProvider *provider);
-       gint             (*get_priority)        (GtkSourceCompletionProvider *provider);
+       gchar                         *(*get_name)              (GtkSourceCompletionProvider *provider);
+       GdkPixbuf                     *(*get_icon)              (GtkSourceCompletionProvider *provider);
+       const gchar                   *(*get_icon_name)         (GtkSourceCompletionProvider *provider);
+       GIcon                         *(*get_gicon)             (GtkSourceCompletionProvider *provider);
+       void                           (*populate)              (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionContext  *context);
+       gboolean                       (*match)                 (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionContext  *context);
+       GtkSourceCompletionActivation  (*get_activation)        (GtkSourceCompletionProvider *provider);
+       GtkWidget                     *(*get_info_widget)       (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionProposal *proposal);
+       void                           (*update_info)           (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionProposal *proposal,
+                                                                GtkSourceCompletionInfo     *info);
+       gboolean                       (*get_start_iter)        (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionContext  *context,
+                                                                GtkSourceCompletionProposal *proposal,
+                                                                GtkTextIter                 *iter);
+       gboolean                       (*activate_proposal)     (GtkSourceCompletionProvider *provider,
+                                                                GtkSourceCompletionProposal *proposal,
+                                                                GtkTextIter                 *iter);
+       gint                           (*get_interactive_delay) (GtkSourceCompletionProvider *provider);
+       gint                           (*get_priority)          (GtkSourceCompletionProvider *provider);
 };
 
 GTK_SOURCE_AVAILABLE_IN_ALL
-GType           gtk_source_completion_provider_get_type        (void);
-
-GTK_SOURCE_AVAILABLE_IN_ALL
-gchar          *gtk_source_completion_provider_get_name        (GtkSourceCompletionProvider *provider);
-
+gchar                         *gtk_source_completion_provider_get_name              
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_ALL
-GdkPixbuf      *gtk_source_completion_provider_get_icon        (GtkSourceCompletionProvider *provider);
-
+GdkPixbuf                     *gtk_source_completion_provider_get_icon              
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_3_18
-const gchar    *gtk_source_completion_provider_get_icon_name   (GtkSourceCompletionProvider *provider);
-
+const gchar                   *gtk_source_completion_provider_get_icon_name         
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_3_18
-GIcon          *gtk_source_completion_provider_get_gicon       (GtkSourceCompletionProvider *provider);
-
+GIcon                         *gtk_source_completion_provider_get_gicon             
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_ALL
-void            gtk_source_completion_provider_populate        (GtkSourceCompletionProvider *provider,
-                                                                GtkSourceCompletionContext  *context);
-
+void                           gtk_source_completion_provider_populate              
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionContext  *context);
 GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourceCompletionActivation
-                gtk_source_completion_provider_get_activation (GtkSourceCompletionProvider *provider);
-
+GtkSourceCompletionActivation  gtk_source_completion_provider_get_activation        
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean        gtk_source_completion_provider_match           (GtkSourceCompletionProvider *provider,
-                                                                GtkSourceCompletionContext  *context);
-
+gboolean                       gtk_source_completion_provider_match                 
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionContext  *context);
 GTK_SOURCE_AVAILABLE_IN_ALL
-GtkWidget      *gtk_source_completion_provider_get_info_widget (GtkSourceCompletionProvider *provider,
-                                                                GtkSourceCompletionProposal *proposal);
-
+GtkWidget                     *gtk_source_completion_provider_get_info_widget       
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionProposal *proposal);
 GTK_SOURCE_AVAILABLE_IN_ALL
-void            gtk_source_completion_provider_update_info     (GtkSourceCompletionProvider *provider,
-                                                                GtkSourceCompletionProposal *proposal,
-                                                                GtkSourceCompletionInfo     *info);
-
+void                           gtk_source_completion_provider_update_info           
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionProposal *proposal,
+                                                                                     GtkSourceCompletionInfo 
    *info);
 GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean        gtk_source_completion_provider_get_start_iter  (GtkSourceCompletionProvider *provider,
-                                                                GtkSourceCompletionContext  *context,
-                                                                GtkSourceCompletionProposal *proposal,
-                                                                GtkTextIter                 *iter);
-
+gboolean                       gtk_source_completion_provider_get_start_iter        
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionContext  *context,
+                                                                                     
GtkSourceCompletionProposal *proposal,
+                                                                                     GtkTextIter             
    *iter);
 GTK_SOURCE_AVAILABLE_IN_ALL
-gboolean        gtk_source_completion_provider_activate_proposal (GtkSourceCompletionProvider *provider,
-                                                                  GtkSourceCompletionProposal *proposal,
-                                                                  GtkTextIter                 *iter);
-
+gboolean                       gtk_source_completion_provider_activate_proposal     
(GtkSourceCompletionProvider *provider,
+                                                                                     
GtkSourceCompletionProposal *proposal,
+                                                                                     GtkTextIter             
    *iter);
 GTK_SOURCE_AVAILABLE_IN_ALL
-gint            gtk_source_completion_provider_get_interactive_delay (GtkSourceCompletionProvider *provider);
-
+gint                           gtk_source_completion_provider_get_interactive_delay 
(GtkSourceCompletionProvider *provider);
 GTK_SOURCE_AVAILABLE_IN_ALL
-gint            gtk_source_completion_provider_get_priority    (GtkSourceCompletionProvider *provider);
+gint                           gtk_source_completion_provider_get_priority          
(GtkSourceCompletionProvider *provider);
 
 G_END_DECLS
diff --git a/tests/test-completion.c b/tests/test-completion.c
index c5b86367..6830d904 100644
--- a/tests/test-completion.c
+++ b/tests/test-completion.c
@@ -52,7 +52,7 @@ struct _TestProviderClass
        GObjectClass parent_class;
 };
 
-static void test_provider_iface_init (GtkSourceCompletionProviderIface *iface);
+static void test_provider_iface_init (GtkSourceCompletionProviderInterface *iface);
 GType test_provider_get_type (void);
 
 G_DEFINE_TYPE_WITH_CODE (TestProvider,
@@ -121,7 +121,7 @@ test_provider_get_icon (GtkSourceCompletionProvider *provider)
 }
 
 static void
-test_provider_iface_init (GtkSourceCompletionProviderIface *iface)
+test_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
 {
        iface->get_name = test_provider_get_name;
        iface->populate = test_provider_populate;
diff --git a/testsuite/test-completion-model.c b/testsuite/test-completion-model.c
index 9ce12c19..c4873727 100644
--- a/testsuite/test-completion-model.c
+++ b/testsuite/test-completion-model.c
@@ -42,7 +42,7 @@ struct _TestProviderClass
 
 GType test_provider_get_type (void);
 
-static void test_provider_iface_init (GtkSourceCompletionProviderIface *iface);
+static void test_provider_iface_init (GtkSourceCompletionProviderInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (TestProvider,
                         test_provider,
@@ -63,7 +63,7 @@ test_provider_get_priority (GtkSourceCompletionProvider *provider)
 }
 
 static void
-test_provider_iface_init (GtkSourceCompletionProviderIface *iface)
+test_provider_iface_init (GtkSourceCompletionProviderInterface *iface)
 {
        iface->get_name = test_provider_get_name;
        iface->get_priority = test_provider_get_priority;


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