[gtksourceview/wip/new-space-drawing-api] SpaceDrawer: new API with two enums (space types vs locations)
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/new-space-drawing-api] SpaceDrawer: new API with two enums (space types vs locations)
- Date: Fri, 23 Sep 2016 18:51:27 +0000 (UTC)
commit d3552c1cf72a04ff6b89f30b7e76e1bd72274b69
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jul 23 17:37:25 2016 +0200
SpaceDrawer: new API with two enums (space types vs locations)
https://bugzilla.gnome.org/show_bug.cgi?id=683678
docs/reference/gtksourceview-3.0-sections.txt | 12 +++
gtksourceview/gtksourcespacedrawer.c | 111 +++++++++++++++++++++++++
gtksourceview/gtksourcespacedrawer.h | 74 ++++++++++++++++
3 files changed, 197 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 3888e2a..47e82ed 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -743,6 +743,14 @@ gtk_source_search_settings_get_type
<FILE>spacedrawer</FILE>
<TITLE>GtkSourceSpaceDrawer</TITLE>
GtkSourceSpaceDrawer
+GtkSourceSpaceTypeFlags
+GtkSourceSpaceLocationFlags
+gtk_source_space_drawer_get_types_for_locations
+gtk_source_space_drawer_set_types_for_locations
+gtk_source_space_drawer_get_locations_for_types
+gtk_source_space_drawer_set_locations_for_types
+gtk_source_space_drawer_get_matrix
+gtk_source_space_drawer_set_matrix
<SUBSECTION Standard>
GTK_SOURCE_IS_SPACE_DRAWER
GTK_SOURCE_IS_SPACE_DRAWER_CLASS
@@ -753,6 +761,10 @@ GTK_SOURCE_TYPE_SPACE_DRAWER
GtkSourceSpaceDrawerClass
GtkSourceSpaceDrawerPrivate
gtk_source_space_drawer_get_type
+GTK_SOURCE_TYPE_SPACE_LOCATION_FLAGS
+GTK_SOURCE_TYPE_SPACE_TYPE_FLAGS
+gtk_source_space_location_flags_get_type
+gtk_source_space_type_flags_get_type
</SECTION>
<SECTION>
diff --git a/gtksourceview/gtksourcespacedrawer.c b/gtksourceview/gtksourcespacedrawer.c
index fc4416e..6d1fa9f 100644
--- a/gtksourceview/gtksourcespacedrawer.c
+++ b/gtksourceview/gtksourcespacedrawer.c
@@ -49,9 +49,58 @@ struct _GtkSourceSpaceDrawerPrivate
GdkRGBA *color;
};
+enum
+{
+ PROP_0,
+ PROP_MATRIX,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES];
+
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceSpaceDrawer, gtk_source_space_drawer, G_TYPE_OBJECT)
static void
+gtk_source_space_drawer_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSourceSpaceDrawer *drawer = GTK_SOURCE_SPACE_DRAWER (object);
+
+ switch (prop_id)
+ {
+ case PROP_MATRIX:
+ g_value_set_variant (value, gtk_source_space_drawer_get_matrix (drawer));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_source_space_drawer_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkSourceSpaceDrawer *drawer = GTK_SOURCE_SPACE_DRAWER (object);
+
+ switch (prop_id)
+ {
+ case PROP_MATRIX:
+ gtk_source_space_drawer_set_matrix (drawer, g_value_get_variant (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
gtk_source_space_drawer_finalize (GObject *object)
{
GtkSourceSpaceDrawer *drawer = GTK_SOURCE_SPACE_DRAWER (object);
@@ -69,7 +118,20 @@ gtk_source_space_drawer_class_init (GtkSourceSpaceDrawerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->get_property = gtk_source_space_drawer_get_property;
+ object_class->set_property = gtk_source_space_drawer_set_property;
object_class->finalize = gtk_source_space_drawer_finalize;
+
+ properties[PROP_MATRIX] =
+ g_param_spec_variant ("matrix",
+ "Matrix",
+ "",
+ G_VARIANT_TYPE ("ai"),
+ g_variant_new ("ai", NULL),
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
static void
@@ -109,6 +171,55 @@ _gtk_source_space_drawer_set_flags (GtkSourceSpaceDrawer *drawer,
return changed;
}
+GtkSourceSpaceTypeFlags
+gtk_source_space_drawer_get_types_for_locations (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceLocationFlags locations)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer), GTK_SOURCE_SPACE_TYPE_NONE);
+
+ return GTK_SOURCE_SPACE_TYPE_NONE;
+}
+
+void
+gtk_source_space_drawer_set_types_for_locations (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceLocationFlags locations,
+ GtkSourceSpaceTypeFlags types)
+{
+ g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
+}
+
+GtkSourceSpaceLocationFlags
+gtk_source_space_drawer_get_locations_for_types (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceTypeFlags types)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer), GTK_SOURCE_SPACE_LOCATION_NONE);
+
+ return GTK_SOURCE_SPACE_LOCATION_NONE;
+}
+
+void
+gtk_source_space_drawer_set_locations_for_types (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceTypeFlags types,
+ GtkSourceSpaceLocationFlags locations)
+{
+ g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
+}
+
+GVariant *
+gtk_source_space_drawer_get_matrix (GtkSourceSpaceDrawer *drawer)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer), NULL);
+
+ return NULL;
+}
+
+void
+gtk_source_space_drawer_set_matrix (GtkSourceSpaceDrawer *drawer,
+ GVariant *matrix)
+{
+ g_return_if_fail (GTK_SOURCE_IS_SPACE_DRAWER (drawer));
+}
+
void
_gtk_source_space_drawer_update_color (GtkSourceSpaceDrawer *drawer,
GtkSourceView *view)
diff --git a/gtksourceview/gtksourcespacedrawer.h b/gtksourceview/gtksourcespacedrawer.h
index 63ca162..8bfa040 100644
--- a/gtksourceview/gtksourcespacedrawer.h
+++ b/gtksourceview/gtksourcespacedrawer.h
@@ -51,9 +51,83 @@ struct _GtkSourceSpaceDrawerClass
gpointer padding[20];
};
+/**
+ * GtkSourceSpaceTypeFlags:
+ * @GTK_SOURCE_SPACE_TYPE_NONE: No flags.
+ * @GTK_SOURCE_SPACE_TYPE_SPACE: Space character.
+ * @GTK_SOURCE_SPACE_TYPE_TAB: Tab character.
+ * @GTK_SOURCE_SPACE_TYPE_NEWLINE: Line break character.
+ * @GTK_SOURCE_SPACE_TYPE_NBSP: Non-breaking space character.
+ * @GTK_SOURCE_SPACE_TYPE_ALL: All whitespaces.
+ *
+ * #GtkSourceSpaceTypeFlags contains flags for whitespace types.
+ *
+ * Since: 3.24
+ */
+typedef enum _GtkSourceSpaceTypeFlags
+{
+ GTK_SOURCE_SPACE_TYPE_NONE = 0,
+ GTK_SOURCE_SPACE_TYPE_SPACE = 1 << 0,
+ GTK_SOURCE_SPACE_TYPE_TAB = 1 << 1,
+ GTK_SOURCE_SPACE_TYPE_NEWLINE = 1 << 2,
+ GTK_SOURCE_SPACE_TYPE_NBSP = 1 << 3,
+ GTK_SOURCE_SPACE_TYPE_ALL = 0xff
+} GtkSourceSpaceTypeFlags;
+
+/**
+ * GtkSourceSpaceLocationFlags:
+ * @GTK_SOURCE_SPACE_LOCATION_NONE: No flags.
+ * @GTK_SOURCE_SPACE_LOCATION_LEADING: Leading whitespaces on a line, i.e. the
+ * indentation.
+ * @GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT: Whitespaces inside a line of text.
+ * @GTK_SOURCE_SPACE_LOCATION_TRAILING: Trailing whitespaces on a line.
+ * @GTK_SOURCE_SPACE_LOCATION_ALL: Whitespaces anywhere.
+ *
+ * #GtkSourceSpaceLocationFlags contains flags for whitespace locations.
+ *
+ * If a line contains only whitespaces (no text), the whitespaces match both
+ * %GTK_SOURCE_SPACE_LOCATION_LEADING and %GTK_SOURCE_SPACE_LOCATION_TRAILING.
+ *
+ * Since: 3.24
+ */
+typedef enum _GtkSourceSpaceLocationFlags
+{
+ GTK_SOURCE_SPACE_LOCATION_NONE = 0,
+ GTK_SOURCE_SPACE_LOCATION_LEADING = 1 << 0,
+ GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT = 1 << 1,
+ GTK_SOURCE_SPACE_LOCATION_TRAILING = 1 << 2,
+ GTK_SOURCE_SPACE_LOCATION_ALL = 0xff
+} GtkSourceSpaceLocationFlags;
+
GTK_SOURCE_AVAILABLE_IN_3_24
GType gtk_source_space_drawer_get_type (void) G_GNUC_CONST;
+GTK_SOURCE_AVAILABLE_IN_3_24
+GtkSourceSpaceTypeFlags gtk_source_space_drawer_get_types_for_locations (GtkSourceSpaceDrawer
*drawer,
+ GtkSourceSpaceLocationFlags
locations);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+void gtk_source_space_drawer_set_types_for_locations (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceLocationFlags
locations,
+ GtkSourceSpaceTypeFlags types);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+GtkSourceSpaceLocationFlags
+ gtk_source_space_drawer_get_locations_for_types (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceTypeFlags types);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+void gtk_source_space_drawer_set_locations_for_types (GtkSourceSpaceDrawer *drawer,
+ GtkSourceSpaceTypeFlags types,
+ GtkSourceSpaceLocationFlags
locations);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+GVariant * gtk_source_space_drawer_get_matrix (GtkSourceSpaceDrawer *drawer);
+
+GTK_SOURCE_AVAILABLE_IN_3_24
+void gtk_source_space_drawer_set_matrix (GtkSourceSpaceDrawer *drawer,
+ GVariant *matrix);
+
G_END_DECLS
#endif /* GTK_SOURCE_SPACE_DRAWER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]