summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testsuite/reftests/Makefile.am4
-rw-r--r--testsuite/reftests/textview-border-windows.c75
-rw-r--r--testsuite/reftests/textview-border-windows.css21
-rw-r--r--testsuite/reftests/textview-border-windows.ref.ui74
-rw-r--r--testsuite/reftests/textview-border-windows.ui20
5 files changed, 194 insertions, 0 deletions
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index d3842e5081..7e296a696d 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -328,6 +328,9 @@ testdata = \
symbolic-icon-translucent-color.css \
symbolic-icon-translucent-color.ref.ui \
symbolic-icon-translucent-color.ui \
+ textview-border-windows.css \
+ textview-border-windows.ref.ui \
+ textview-border-windows.ui \
textview-margins.css \
textview-margins.ref.ui \
textview-margins.ui \
@@ -372,6 +375,7 @@ libreftest_la_LIBADD = $(gtk_reftest_LDADD)
libreftest_la_SOURCES = \
set-default-direction.c \
expand-expander.c \
+ textview-border-windows.c \
$(NULL)
substitutions = \
diff --git a/testsuite/reftests/textview-border-windows.c b/testsuite/reftests/textview-border-windows.c
new file mode 100644
index 0000000000..502b18b06d
--- /dev/null
+++ b/testsuite/reftests/textview-border-windows.c
@@ -0,0 +1,75 @@
+/*
+ * 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>
+
+static void
+paint_border (GtkTextView *text_view,
+ cairo_t *cr,
+ GtkTextWindowType type,
+ GtkStyleContext *context,
+ const char *class)
+{
+ GdkWindow *window;
+
+ window = gtk_text_view_get_window (text_view, type);
+
+ if (window != NULL &&
+ gtk_cairo_should_draw_window (cr, window))
+ {
+ gint w, h;
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, class);
+
+ w = gdk_window_get_width (window);
+ h = gdk_window_get_height (window);
+
+ gtk_cairo_transform_to_window (cr, GTK_WIDGET (text_view), window);
+
+ cairo_save (cr);
+ gtk_render_background (context, cr, 0, 0, w, h);
+ cairo_restore (cr);
+
+ gtk_style_context_restore (context);
+ }
+}
+
+G_MODULE_EXPORT gboolean
+paint_border_windows (GtkTextView *text_view,
+ cairo_t *cr)
+{
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
+
+ paint_border (text_view, cr, GTK_TEXT_WINDOW_LEFT, context, "left");
+ paint_border (text_view, cr, GTK_TEXT_WINDOW_RIGHT, context, "right");
+ paint_border (text_view, cr, GTK_TEXT_WINDOW_TOP, context, "top");
+ paint_border (text_view, cr, GTK_TEXT_WINDOW_BOTTOM, context, "bottom");
+
+ return FALSE;
+}
+
+G_MODULE_EXPORT void
+add_border_windows (GtkTextView *text_view)
+{
+ gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_LEFT, 30);
+ gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_RIGHT, 30);
+ gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_TOP, 30);
+ gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_BOTTOM, 30);
+}
diff --git a/testsuite/reftests/textview-border-windows.css b/testsuite/reftests/textview-border-windows.css
new file mode 100644
index 0000000000..79eb97103e
--- /dev/null
+++ b/testsuite/reftests/textview-border-windows.css
@@ -0,0 +1,21 @@
+@import "reset-to-defaults.css";
+
+.top,
+#label_n {
+ background-color: blue;
+}
+
+.left,
+#label_w {
+ background-color: green;
+}
+
+.right,
+#label_e {
+ background-color: yellow;
+}
+
+.bottom,
+#label_s {
+ background-color: red;
+}
diff --git a/testsuite/reftests/textview-border-windows.ref.ui b/testsuite/reftests/textview-border-windows.ref.ui
new file mode 100644
index 0000000000..642feb1694
--- /dev/null
+++ b/testsuite/reftests/textview-border-windows.ref.ui
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="width_request">100</property>
+ <property name="height_request">100</property>
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_n">
+ <property name="name">label_n</property>
+ <property name="height_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_w">
+ <property name="name">label_w</property>
+ <property name="width_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_e">
+ <property name="name">label_e</property>
+ <property name="width_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_s">
+ <property name="name">label_s</property>
+ <property name="height_request">30</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/testsuite/reftests/textview-border-windows.ui b/testsuite/reftests/textview-border-windows.ui
new file mode 100644
index 0000000000..7aa6b22fc6
--- /dev/null
+++ b/testsuite/reftests/textview-border-windows.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.0"/>
+ <object class="GtkWindow" id="window">
+ <property name="can_focus">False</property>
+ <property name="type">popup</property>
+ <child>
+ <object class="GtkTextView" id="textview1">
+ <property name="width_request">160</property>
+ <property name="height_request">160</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="wrap_mode">word</property>
+ <signal name="map" handler="reftest:add_border_windows" swapped="no"/>
+ <signal name="draw" handler="reftest:paint_border_windows" swapped="no"/>
+ </object>
+ </child>
+ </object>
+</interface>