[gtksourceview/wip/engine-iface] Transform GtkSourceEngine into an interface
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/engine-iface] Transform GtkSourceEngine into an interface
- Date: Tue, 10 Sep 2013 15:27:12 +0000 (UTC)
commit ec737161762713e62eacdbe04fe84bbb4434d8d6
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Sep 10 17:16:01 2013 +0200
Transform GtkSourceEngine into an interface
The ContextEngine is the only implementation.
gtksourceview/gtksourcecontextengine.c | 28 +++++++++++-----
gtksourceview/gtksourcecontextengine.h | 4 +-
gtksourceview/gtksourceengine.c | 52 +++++++++++++------------------
gtksourceview/gtksourceengine.h | 21 ++++--------
4 files changed, 50 insertions(+), 55 deletions(-)
---
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index 82fcdec..8e0472e 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -2404,7 +2404,14 @@ install_first_update (GtkSourceContextEngine *ce)
/* GtkSourceContextEngine class ------------------------------------------- */
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceContextEngine, _gtk_source_context_engine, GTK_SOURCE_TYPE_ENGINE)
+static void _gtk_source_engine_interface_init (GtkSourceEngineInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkSourceContextEngine,
+ _gtk_source_context_engine,
+ G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GtkSourceContextEngine)
+ G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_ENGINE,
+ _gtk_source_engine_interface_init))
static GQuark
gtk_source_context_engine_error_quark (void)
@@ -2684,19 +2691,22 @@ gtk_source_context_engine_get_context_class_tag (GtkSourceEngine *engine,
}
static void
+_gtk_source_engine_interface_init (GtkSourceEngineInterface *iface)
+{
+ iface->attach_buffer = gtk_source_context_engine_attach_buffer;
+ iface->text_inserted = gtk_source_context_engine_text_inserted;
+ iface->text_deleted = gtk_source_context_engine_text_deleted;
+ iface->update_highlight = gtk_source_context_engine_update_highlight;
+ iface->set_style_scheme = gtk_source_context_engine_set_style_scheme;
+ iface->get_context_class_tag = gtk_source_context_engine_get_context_class_tag;
+}
+
+static void
_gtk_source_context_engine_class_init (GtkSourceContextEngineClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkSourceEngineClass *engine_class = GTK_SOURCE_ENGINE_CLASS (klass);
object_class->finalize = gtk_source_context_engine_finalize;
-
- engine_class->attach_buffer = gtk_source_context_engine_attach_buffer;
- engine_class->text_inserted = gtk_source_context_engine_text_inserted;
- engine_class->text_deleted = gtk_source_context_engine_text_deleted;
- engine_class->update_highlight = gtk_source_context_engine_update_highlight;
- engine_class->set_style_scheme = gtk_source_context_engine_set_style_scheme;
- engine_class->get_context_class_tag = gtk_source_context_engine_get_context_class_tag;
}
static void
diff --git a/gtksourceview/gtksourcecontextengine.h b/gtksourceview/gtksourcecontextengine.h
index e0aa60a..b12a5ca 100644
--- a/gtksourceview/gtksourcecontextengine.h
+++ b/gtksourceview/gtksourcecontextengine.h
@@ -44,7 +44,7 @@ typedef struct _GtkSourceContextEnginePrivate GtkSourceContextEnginePrivate;
struct _GtkSourceContextEngine
{
- GtkSourceEngine parent_instance;
+ GObject parent_instance;
/*< private >*/
GtkSourceContextEnginePrivate *priv;
@@ -52,7 +52,7 @@ struct _GtkSourceContextEngine
struct _GtkSourceContextEngineClass
{
- GtkSourceEngineClass parent_class;
+ GObjectClass parent_class;
};
typedef enum {
diff --git a/gtksourceview/gtksourceengine.c b/gtksourceview/gtksourceengine.c
index 5e3f732..3e6fb4c 100644
--- a/gtksourceview/gtksourceengine.c
+++ b/gtksourceview/gtksourceengine.c
@@ -23,32 +23,24 @@
#include <config.h>
#endif
-#include "gtksourcebuffer.h"
#include "gtksourceengine.h"
#include "gtksourcestylescheme.h"
-G_DEFINE_TYPE (GtkSourceEngine, _gtk_source_engine, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (GtkSourceEngine, _gtk_source_engine, G_TYPE_OBJECT)
static void
-_gtk_source_engine_class_init (GtkSourceEngineClass *klass)
-{
- klass->attach_buffer = NULL;
-}
-
-
-static void
-_gtk_source_engine_init (G_GNUC_UNUSED GtkSourceEngine *engine)
+_gtk_source_engine_default_init (GtkSourceEngineInterface *interface)
{
}
void
_gtk_source_engine_attach_buffer (GtkSourceEngine *engine,
- GtkTextBuffer *buffer)
+ GtkTextBuffer *buffer)
{
g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine));
- g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->attach_buffer != NULL);
+ g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->attach_buffer != NULL);
- GTK_SOURCE_ENGINE_GET_CLASS (engine)->attach_buffer (engine, buffer);
+ GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->attach_buffer (engine, buffer);
}
void
@@ -57,11 +49,11 @@ _gtk_source_engine_text_inserted (GtkSourceEngine *engine,
gint end_offset)
{
g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine));
- g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->text_inserted != NULL);
+ g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->text_inserted != NULL);
- GTK_SOURCE_ENGINE_GET_CLASS (engine)->text_inserted (engine,
- start_offset,
- end_offset);
+ GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->text_inserted (engine,
+ start_offset,
+ end_offset);
}
void
@@ -70,11 +62,11 @@ _gtk_source_engine_text_deleted (GtkSourceEngine *engine,
gint length)
{
g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine));
- g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->text_deleted != NULL);
+ g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->text_deleted != NULL);
- GTK_SOURCE_ENGINE_GET_CLASS (engine)->text_deleted (engine,
- offset,
- length);
+ GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->text_deleted (engine,
+ offset,
+ length);
}
void
@@ -85,12 +77,12 @@ _gtk_source_engine_update_highlight (GtkSourceEngine *engine,
{
g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine));
g_return_if_fail (start != NULL && end != NULL);
- g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->update_highlight != NULL);
+ g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->update_highlight != NULL);
- GTK_SOURCE_ENGINE_GET_CLASS (engine)->update_highlight (engine,
- start,
- end,
- synchronous);
+ GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->update_highlight (engine,
+ start,
+ end,
+ synchronous);
}
void
@@ -99,9 +91,9 @@ _gtk_source_engine_set_style_scheme (GtkSourceEngine *engine,
{
g_return_if_fail (GTK_SOURCE_IS_ENGINE (engine));
g_return_if_fail (GTK_SOURCE_IS_STYLE_SCHEME (scheme) || scheme == NULL);
- g_return_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->set_style_scheme != NULL);
+ g_return_if_fail (GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->set_style_scheme != NULL);
- GTK_SOURCE_ENGINE_GET_CLASS (engine)->set_style_scheme (engine, scheme);
+ GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->set_style_scheme (engine, scheme);
}
GtkTextTag *
@@ -111,6 +103,6 @@ _gtk_source_engine_get_context_class_tag (GtkSourceEngine *engine,
g_return_val_if_fail (GTK_SOURCE_IS_ENGINE (engine), NULL);
g_return_val_if_fail (context_class != NULL, NULL);
- return GTK_SOURCE_ENGINE_GET_CLASS (engine)->get_context_class_tag (engine,
- context_class);
+ return GTK_SOURCE_ENGINE_GET_INTERFACE (engine)->get_context_class_tag (engine,
+ context_class);
}
diff --git a/gtksourceview/gtksourceengine.h b/gtksourceview/gtksourceengine.h
index 045a3f1..dc4c64d 100644
--- a/gtksourceview/gtksourceengine.h
+++ b/gtksourceview/gtksourceengine.h
@@ -28,23 +28,16 @@
G_BEGIN_DECLS
-#define GTK_SOURCE_TYPE_ENGINE (_gtk_source_engine_get_type ())
-#define GTK_SOURCE_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_ENGINE,
GtkSourceEngine))
-#define GTK_SOURCE_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_SOURCE_TYPE_ENGINE,
GtkSourceEngineClass))
-#define GTK_SOURCE_IS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_TYPE_ENGINE))
-#define GTK_SOURCE_IS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_SOURCE_TYPE_ENGINE))
-#define GTK_SOURCE_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_SOURCE_TYPE_ENGINE,
GtkSourceEngineClass))
+#define GTK_SOURCE_TYPE_ENGINE (_gtk_source_engine_get_type ())
+#define GTK_SOURCE_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_SOURCE_TYPE_ENGINE,
GtkSourceEngine))
+#define GTK_SOURCE_IS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_SOURCE_TYPE_ENGINE))
+#define GTK_SOURCE_ENGINE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_SOURCE_TYPE_ENGINE,
GtkSourceEngineInterface))
-typedef struct _GtkSourceEngineClass GtkSourceEngineClass;
+typedef struct _GtkSourceEngineInterface GtkSourceEngineInterface;
-struct _GtkSourceEngine
+struct _GtkSourceEngineInterface
{
- GObject parent_instance;
-};
-
-struct _GtkSourceEngineClass
-{
- GObjectClass parent_class;
+ GTypeInterface parent_interface;
void (* attach_buffer) (GtkSourceEngine *engine,
GtkTextBuffer *buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]