[gtk+] Add some reftests related to textview tags



commit 8615a52ca3bdc3c49c9829cb461f3cc9c764959f
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Mar 11 21:45:48 2015 -0400

    Add some reftests related to textview tags
    
    This test shows that a) tags override the text view style and
    b) tags override each other in the expected way.

 testsuite/reftests/Makefile.am          |    3 ++
 testsuite/reftests/textview-tags.c      |   57 +++++++++++++++++++++++++++++++
 testsuite/reftests/textview-tags.css    |    6 +++
 testsuite/reftests/textview-tags.ref.ui |   49 ++++++++++++++++++++++++++
 testsuite/reftests/textview-tags.ui     |   49 ++++++++++++++++++++++++++
 5 files changed, 164 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index 607a4f1..d8b8010 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -418,6 +418,8 @@ testdata = \
        textview-margins.css \
        textview-margins.ref.ui \
        textview-margins.ui \
+       textview-tags.ref.ui \
+       textview-tags.ui \
        toplevel-vs-popup.ref.ui \
        toplevel-vs-popup.ui \
        treeview-crash-too-wide.ref.ui \
@@ -493,6 +495,7 @@ libreftest_la_SOURCES =                     \
        set-default-direction.c         \
        statusbar-remove-all.c          \
        textview-border-windows.c       \
+       textview-tags.c                 \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/testsuite/reftests/textview-tags.c b/testsuite/reftests/textview-tags.c
new file mode 100644
index 0000000..5a49023
--- /dev/null
+++ b/testsuite/reftests/textview-tags.c
@@ -0,0 +1,57 @@
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+
+G_MODULE_EXPORT void
+apply_tags_blue (GtkTextView *text_view)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
+  GtkTextIter four, eight;
+
+  buffer = gtk_text_view_get_buffer (text_view);
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "blue", &start, &end);
+  four = start;
+  eight = start;
+  gtk_text_iter_forward_chars (&four, 4);
+  gtk_text_iter_forward_chars (&eight, 8);
+  gtk_text_buffer_apply_tag_by_name (buffer, "black", &four, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "white", &eight, &end);
+}
+
+G_MODULE_EXPORT void
+apply_tags_red_blue (GtkTextView *text_view)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
+  GtkTextIter four, eight;
+
+  buffer = gtk_text_view_get_buffer (text_view);
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "red", &start, &end);
+  gtk_text_buffer_apply_tag_by_name (buffer, "blue", &start, &end);
+  four = start;
+  eight = start;
+  gtk_text_iter_forward_chars (&four, 4);
+  gtk_text_iter_forward_chars (&eight, 8);
+  gtk_text_buffer_apply_tag_by_name (buffer, "black", &four, &eight);
+  gtk_text_buffer_apply_tag_by_name (buffer, "white", &eight, &end);
+}
diff --git a/testsuite/reftests/textview-tags.css b/testsuite/reftests/textview-tags.css
new file mode 100644
index 0000000..899bbeb
--- /dev/null
+++ b/testsuite/reftests/textview-tags.css
@@ -0,0 +1,6 @@
+ import "reset-to-defaults.css";
+
+GtkTextView {
+  color: yellow;
+  background-color: yellow;
+}
diff --git a/testsuite/reftests/textview-tags.ref.ui b/testsuite/reftests/textview-tags.ref.ui
new file mode 100644
index 0000000..8b9fede
--- /dev/null
+++ b/testsuite/reftests/textview-tags.ref.ui
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <object class="GtkTextTagTable" id="texttagtable1">
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">red</property>
+        <property name="foreground">red</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">blue</property>
+        <property name="foreground">blue</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">black</property>
+        <property name="foreground">black</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">white</property>
+        <property name="foreground">white</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+  </object>
+  <object class="GtkTextBuffer" id="textbuffer1">
+    <property name="tag_table">texttagtable1</property>
+    <property name="text" translatable="yes">red or blue or what</property>
+  </object>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkTextView" id="textview1">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="buffer">textbuffer1</property>
+        <signal name="map" handler="reftest:apply_tags_red_blue" swapped="no"/>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/reftests/textview-tags.ui b/testsuite/reftests/textview-tags.ui
new file mode 100644
index 0000000..c04ebf0
--- /dev/null
+++ b/testsuite/reftests/textview-tags.ui
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <object class="GtkTextTagTable" id="texttagtable1">
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">red</property>
+        <property name="foreground">red</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">blue</property>
+        <property name="foreground">blue</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">black</property>
+        <property name="foreground">black</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+    <child type="tag">
+      <object class="GtkTextTag">
+        <property name="name">white</property>
+        <property name="foreground">white</property>
+        <property name="font">Normal</property>
+      </object>
+    </child>
+  </object>
+  <object class="GtkTextBuffer" id="textbuffer1">
+    <property name="tag_table">texttagtable1</property>
+    <property name="text" translatable="yes">red or blue or what</property>
+  </object>
+  <object class="GtkWindow" id="window1">
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkTextView" id="textview1">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="buffer">textbuffer1</property>
+        <signal name="map" handler="reftest:apply_tags_blue" swapped="no"/>
+      </object>
+    </child>
+  </object>
+</interface>


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