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.
This commit is contained in:
Matthias Clasen 2015-03-11 21:45:48 -04:00
parent 7ad203732f
commit 8615a52ca3
5 changed files with 164 additions and 0 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -0,0 +1,6 @@
@import "reset-to-defaults.css";
GtkTextView {
color: yellow;
background-color: yellow;
}

View File

@ -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>

View File

@ -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>