Compare commits

...

38 Commits

Author SHA1 Message Date
Emmanuele Bassi 24b69a9a10 examples: Update to bind settings inside UI definitions 2021-09-09 19:22:48 +01:00
Emmanuele Bassi 043eea6ae3 docs: Document the settings binding in GtkBuilder UI files
And clean up the structure while we're at it.
2021-09-09 19:22:06 +01:00
Emmanuele Bassi 181fce8342 Support binding properties to GSettings keys in GtkBuilder
We already support binding properties; by adding new attributes to the
`property` element we can automatically call g_settings_bind() on the
object ourselves.
2021-09-09 19:12:40 +01:00
Boyuan Yang db3858a204 Update Chinese (China) translation 2021-09-05 20:33:21 +00:00
Daniel Șerbănescu 07bff74544 Update Romanian translation
(cherry picked from commit bb72acf9cd)
2021-09-05 18:43:44 +00:00
Daniel Șerbănescu b4262883a8 Update Romanian translation
(cherry picked from commit 63d829bbc1)
2021-09-05 18:34:37 +00:00
Matthias Clasen 563c85e222 Merge branch 'matthiasc/for-master' into 'master'
inspector: Cosmetics

See merge request GNOME/gtk!3925
2021-09-05 17:26:13 +00:00
Matthias Clasen d75246a543 inspector: Cosmetics
Make some settings entries smaller, and make the
scales match in size. Also, inline adjustments
in the ui file, since we can do that now.
2021-09-05 12:59:11 -04:00
Matthias Clasen b3856a3ea0 Merge branch 'matthiasc/for-master' into 'master'
Avoid hand-rolled color glyph information

See merge request GNOME/gtk!3924
2021-09-05 16:12:34 +00:00
Matthias Clasen bd4d24f8ed Bump pango req to 1.49.1
We are using pango api that was introduced in 1.49.1
without ifdefs, so we should require it.
2021-09-05 10:58:50 -04:00
Matthias Clasen 65ce3eb207 Avoid hand-rolled color glyph information
Followup to b244f31337. Pango provides color glyph
information for us now, so we don't need to steal a
bit anymore.
2021-09-05 10:58:50 -04:00
Anders Jonsson 865ac44963 Update Swedish translation
(cherry picked from commit 19af960163)
2021-09-05 14:11:51 +00:00
Yaron Shahrabani 55a935db53 Update Hebrew translation 2021-09-05 13:45:49 +00:00
Matthias Clasen 6fefae3dbb Merge branch 'better-font-rendering-demo' into 'master'
gtk-demo: Improve the font rendering demo

See merge request GNOME/gtk!3923
2021-09-05 04:21:29 +00:00
Matthias Clasen f7c84ddc7f gtk-demo: Font rendering - Add some bling
Fade the outlines and pixels in and out.
2021-09-04 23:41:44 -04:00
Matthias Clasen f4a4dd2615 gtk-demo: Font rendering - expand docs 2021-09-04 23:05:55 -04:00
Matthias Clasen b718d99d1f gtk-demo: Font rendering - Add keynav
Add mnemonics to most controls, and make
Ctrl+/- change the zoom.
2021-09-04 23:00:17 -04:00
Matthias Clasen c7215d1199 gtk-demo: Font rendering - add outlines
Should outlines as well.
2021-09-04 22:56:07 -04:00
Matthias Clasen 24d69ef125 gtk-demo: Font rendering - better start
Turn antialiasing on initially, and turn the
extents and grid off. Otherwise we show pretty
shocking rendering right from the start.
2021-09-04 22:56:07 -04:00
Matthias Clasen 7c3fbdecf2 gtk-demo: Font rendering - improve the grid
Allow changing the character shown in the grid.
2021-09-04 22:56:07 -04:00
Matthias Clasen b77938f40f Cosmetics
Remove an unused object from the font rendering
demo ui file.
2021-09-04 22:55:47 -04:00
Matthias Clasen f703744564 Merge branch 'ebassi/accel-parse-doc' into 'master'
Improve the gtk_accelerator_parse() docs

See merge request GNOME/gtk!3921
2021-09-04 23:39:10 +00:00
Matthias Clasen a3ccff3773 Merge branch 'text-fixes' into 'master'
textview: fix pango context invalidation

See merge request GNOME/gtk!3922
2021-09-04 21:39:30 +00:00
Asier Sarasua Garmendia 9869082c1c Update Basque translation
(cherry picked from commit 0768addbb3)
2021-09-04 20:54:41 +00:00
Matthias Clasen 754212d0f9 textview: Invalidate Pango contexts
We need to invalidate the Pango contexts when
font settings change. Use the new helper
gtk_widget_update_pango_context to make it less
likely that we forget to update some things.
2021-09-04 15:42:05 -04:00
Matthias Clasen a9b81577c6 widget: Provide a helper for updating pango contexts 2021-09-04 15:42:05 -04:00
Matthias Clasen eaa2dada54 Rename an internal function
It occupies a name I want to reuse for something else.
2021-09-04 15:42:05 -04:00
Matthias Clasen ce2b2128bb Revert "gsk: Add font options to text nodes"
This reverts commit f1347f5841.
2021-09-04 15:42:05 -04:00
Matthias Clasen 41c25b8809 Revert "gsk: Add font options to the glyph cache"
This reverts commit 6599cb001f.
2021-09-04 15:42:05 -04:00
Matthias Clasen b5ff35ff3e Revert "gsk: Pass font options along"
This reverts commit 299c7c3514.
2021-09-04 15:42:05 -04:00
Matthias Clasen 06423d807f Revert "gtk: Pass font options along"
This reverts commit 062a15310a.
2021-09-04 15:42:05 -04:00
Goran Vidović 0395395d52 Update Croatian translation
(cherry picked from commit 6fe3b21a01)
2021-09-04 18:12:03 +00:00
Emmanuele Bassi c3ca48b249 Improve the gtk_accelerator_parse() docs
We need to escape the modifiers in angular brackets, or Markdown will
consider them as HTML tags.

We also should document the modifiers we're parsing.
2021-09-04 18:56:08 +01:00
Boyuan Yang 464e0aed04 Update Chinese (China) translation 2021-09-04 17:38:16 +00:00
Goran Vidović d46e4fcecd Update Croatian translation
(cherry picked from commit 543b7defec)
2021-09-04 17:16:26 +00:00
Changwoo Ryu 363fb96e81 Update Korean translation 2021-09-04 09:02:48 +00:00
Changwoo Ryu 2382bd3bb2 Update Korean translation
(cherry picked from commit 0a5af76932)
2021-09-04 08:59:40 +00:00
Anders Jonsson 3b0a9e84ab Update Swedish translation
(cherry picked from commit 2dbcad428a)
2021-09-03 22:59:37 +00:00
35 changed files with 18853 additions and 17356 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ if ! pkg-config --atleast-version=2.66.0 glib-2.0; then
fi
pkg-config --modversion glib-2.0
if ! pkg-config --atleast-version=1.49.0 pango; then
if ! pkg-config --atleast-version=1.49.1 pango; then
git clone https://gitlab.gnome.org/GNOME/pango.git _pango
meson setup _pango_build _pango
meson compile -C _pango_build
+152 -13
View File
@@ -1,6 +1,11 @@
/* Pango/Font Rendering
*
* Demonstrates various aspects of font rendering.
* Demonstrates various aspects of font rendering,
* such as hinting, antialiasing and grid alignment.
*
* The demo lets you explore font rendering options
* interactively to get a feeling for they affect the
* shape and positioning of the glyphs.
*/
#include <gtk/gtk.h>
@@ -17,10 +22,14 @@ static GtkWidget *down_button = NULL;
static GtkWidget *text_radio = NULL;
static GtkWidget *show_grid = NULL;
static GtkWidget *show_extents = NULL;
static GtkWidget *show_pixels = NULL;
static GtkWidget *show_outlines = NULL;
static PangoContext *context;
static int scale = 9;
static int scale = 7;
static double pixel_alpha = 1.0;
static double outline_alpha = 0.0;
static void
update_image (void)
@@ -39,6 +48,7 @@ update_image (void)
cairo_hint_style_t hintstyle;
cairo_hint_metrics_t hintmetrics;
cairo_antialias_t antialias;
cairo_path_t *path;
if (!context)
context = gtk_widget_create_pango_context (image);
@@ -94,10 +104,14 @@ update_image (void)
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_source_rgba (cr, 0, 0, 0, pixel_alpha);
cairo_move_to (cr, 10, 10);
pango_cairo_show_layout (cr, layout);
pango_cairo_layout_path (cr, layout);
path = cairo_copy_path (cr);
cairo_destroy (cr);
g_object_unref (layout);
@@ -136,7 +150,7 @@ update_image (void)
if (gtk_check_button_get_active (GTK_CHECK_BUTTON (show_extents)))
{
cairo_set_source_rgba (cr, 0, 0, 1, 1);
cairo_set_source_rgb (cr, 0, 0, 1);
cairo_rectangle (cr,
scale * (10 + pango_units_to_double (logical.x)) - 0.5,
@@ -149,7 +163,7 @@ update_image (void)
cairo_line_to (cr, scale * (10 + pango_units_to_double (logical.x + logical.width)) + 1,
scale * (10 + pango_units_to_double (baseline)) - 0.5);
cairo_stroke (cr);
cairo_set_source_rgba (cr, 1, 0, 0, 1);
cairo_set_source_rgb (cr, 1, 0, 0);
cairo_rectangle (cr,
scale * (10 + pango_units_to_double (pink.x)) + 0.5,
scale * (10 + pango_units_to_double (pink.y)) + 0.5,
@@ -158,8 +172,36 @@ update_image (void)
cairo_stroke (cr);
}
for (int i = 0; i < path->num_data; i += path->data[i].header.length)
{
cairo_path_data_t *data = &path->data[i];
switch (data->header.type)
{
case CAIRO_PATH_CURVE_TO:
data[3].point.x *= scale; data[3].point.y *= scale;
data[2].point.x *= scale; data[2].point.y *= scale;
data[1].point.x *= scale; data[1].point.y *= scale;
break;
case CAIRO_PATH_LINE_TO:
case CAIRO_PATH_MOVE_TO:
data[1].point.x *= scale; data[1].point.y *= scale;
break;
case CAIRO_PATH_CLOSE_PATH:
break;
default:
g_assert_not_reached ();
}
}
cairo_set_source_rgba (cr, 0, 0, 1, outline_alpha);
cairo_move_to (cr, scale * 20 - 0.5, scale * 20 - 0.5);
cairo_append_path (cr, path);
cairo_stroke (cr);
cairo_surface_destroy (surface);
cairo_destroy (cr);
cairo_path_destroy (path);
}
else
{
@@ -167,10 +209,26 @@ update_image (void)
PangoLayoutRun *run;
PangoGlyphInfo *g;
int i, j;
GString *str;
gunichar ch;
if (*text == '\0')
text = " ";
ch = g_utf8_get_char (text);
str = g_string_new ("");
for (i = 0; i < 4; i++)
{
g_string_append_unichar (str, ch);
g_string_append_unichar (str, 0x200c);
}
layout = pango_layout_new (context);
pango_layout_set_font_description (layout, desc);
pango_layout_set_text (layout, "aaaa", -1);
pango_layout_set_text (layout, str->str, -1);
g_string_free (str, TRUE);
pango_layout_get_extents (layout, &ink, &logical);
pango_extents_to_pixels (&logical, NULL);
@@ -185,7 +243,7 @@ update_image (void)
cairo_set_source_rgb (cr, 0, 0, 0);
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[i]);
g = &(run->glyphs->glyphs[2*i]);
g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2);
}
@@ -193,7 +251,7 @@ update_image (void)
{
for (i = 0; i < 4; i++)
{
g = &(run->glyphs->glyphs[i]);
g = &(run->glyphs->glyphs[2*i]);
g->geometry.x_offset = i * (PANGO_SCALE / 4);
g->geometry.y_offset = j * (PANGO_SCALE / 4);
}
@@ -212,7 +270,6 @@ update_image (void)
cairo_surface_destroy (surface);
}
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
g_object_unref (pixbuf2);
@@ -220,6 +277,78 @@ update_image (void)
pango_font_description_free (desc);
}
static gboolean fading = FALSE;
static double start_pixel_alpha;
static double end_pixel_alpha;
static double start_outline_alpha;
static double end_outline_alpha;
static gint64 start_time;
static gint64 end_time;
static double
ease_out_cubic (double t)
{
double p = t - 1;
return p * p * p + 1;
}
static gboolean
change_alpha (GtkWidget *widget,
GdkFrameClock *clock,
gpointer user_data)
{
gint64 now = g_get_monotonic_time ();
double t;
t = ease_out_cubic ((now - start_time) / (double) (end_time - start_time));
pixel_alpha = start_pixel_alpha + (end_pixel_alpha - start_pixel_alpha) * t;
outline_alpha = start_outline_alpha + (end_outline_alpha - start_outline_alpha) * t;
update_image ();
if (now >= end_time)
{
fading = FALSE;
return G_SOURCE_REMOVE;
}
return G_SOURCE_CONTINUE;
}
static void
start_alpha_fade (void)
{
gboolean pixels;
gboolean outlines;
if (fading)
return;
pixels = gtk_check_button_get_active (GTK_CHECK_BUTTON (show_pixels));
outlines = gtk_check_button_get_active (GTK_CHECK_BUTTON (show_outlines));
start_pixel_alpha = pixel_alpha;
if (pixels && outlines)
end_pixel_alpha = 0.5;
else if (pixels)
end_pixel_alpha = 1;
else
end_pixel_alpha = 0;
start_outline_alpha = outline_alpha;
if (outlines)
end_outline_alpha = 1.0;
else
end_outline_alpha = 0.0;
start_time = g_get_monotonic_time ();
end_time = start_time + G_TIME_SPAN_SECOND / 2;
fading = TRUE;
gtk_widget_add_tick_callback (window, change_alpha, NULL, NULL);
}
static void
update_buttons (void)
{
@@ -227,20 +356,26 @@ update_buttons (void)
gtk_widget_set_sensitive (down_button, scale > 1);
}
static void
scale_up (void)
static gboolean
scale_up (GtkWidget *widget,
GVariant *args,
gpointer user_data)
{
scale += 1;
update_buttons ();
update_image ();
return TRUE;
}
static void
scale_down (void)
static gboolean
scale_down (GtkWidget *widget,
GVariant *args,
gpointer user_data)
{
scale -= 1;
update_buttons ();
update_image ();
return TRUE;
}
GtkWidget *
@@ -266,6 +401,8 @@ do_fontrendering (GtkWidget *do_widget)
text_radio = GTK_WIDGET (gtk_builder_get_object (builder, "text_radio"));
show_grid = GTK_WIDGET (gtk_builder_get_object (builder, "show_grid"));
show_extents = GTK_WIDGET (gtk_builder_get_object (builder, "show_extents"));
show_pixels = GTK_WIDGET (gtk_builder_get_object (builder, "show_pixels"));
show_outlines = GTK_WIDGET (gtk_builder_get_object (builder, "show_outlines"));
g_signal_connect (up_button, "clicked", G_CALLBACK (scale_up), NULL);
g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL);
@@ -277,6 +414,8 @@ do_fontrendering (GtkWidget *do_widget)
g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_grid, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_extents, "notify::active", G_CALLBACK (update_image), NULL);
g_signal_connect (show_pixels, "notify::active", G_CALLBACK (start_alpha_fade), NULL);
g_signal_connect (show_outlines, "notify::active", G_CALLBACK (start_alpha_fade), NULL);
update_image ();
+80 -35
View File
@@ -1,13 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="scale_adj">
<property name="upper">24</property>
<property name="step-increment">1</property>
<property name="page-increment">4</property>
</object>
<object class="GtkWindow" id="window">
<property name="default-width">1080</property>
<property name="default-height">430</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<child type="title">
@@ -87,20 +82,20 @@
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">Hinting</property>
<property name="xalign">1</property>
<style>
<class name="dim-label"/>
</style>
<object class="GtkCheckButton" id="show_pixels">
<property name="label">Show _Pixels</property>
<property name="use-underline">1</property>
<property name="active">1</property>
<layout>
<property name="column">3</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="antialias">
<property name="label">Antialias</property>
<object class="GtkCheckButton" id="show_outlines">
<property name="label">Show _Outline</property>
<property name="use-underline">1</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
@@ -108,45 +103,73 @@
</object>
</child>
<child>
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
<object class="GtkBox">
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="label">_Hinting</property>
<property name="use-underline">1</property>
<property name="mnemonic-widget">hinting</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkComboBoxText" id="hinting">
<property name="active">0</property>
<property name="valign">center</property>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="slight">Slight</item>
<item translatable="yes" id="medium">Medium</item>
<item translatable="yes" id="full">Full</item>
</items>
</object>
</child>
<layout>
<property name="column">4</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="antialias">
<property name="label">_Antialias</property>
<property name="use-underline">1</property>
<property name="active">1</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="hint_metrics">
<property name="label">Hint Metrics</property>
<property name="label">Hint _Metrics</property>
<property name="use-underline">1</property>
<layout>
<property name="column">4</property>
<property name="column">5</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_extents">
<property name="label">Show Extents</property>
<property name="active">1</property>
<property name="label">Show _Extents</property>
<property name="use-underline">1</property>
<layout>
<property name="column">5</property>
<property name="column">6</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="show_grid">
<property name="active">1</property>
<property name="label">Show Grid</property>
<property name="label">Show _Grid</property>
<property name="use-underline">1</property>
<layout>
<property name="column">5</property>
<property name="column">6</property>
<property name="row">1</property>
</layout>
</object>
@@ -157,8 +180,19 @@
<style>
<class name="circular"/>
</style>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;plus</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
<layout>
<property name="column">6</property>
<property name="column">7</property>
<property name="row">0</property>
</layout>
</object>
@@ -169,8 +203,19 @@
<style>
<class name="circular"/>
</style>
<child>
<object class="GtkShortcutController">
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;minus</property>
<property name="action">activate</property>
</object>
</child>
</object>
</child>
<layout>
<property name="column">6</property>
<property name="column">7</property>
<property name="row">1</property>
</layout>
</object>
@@ -179,7 +224,7 @@
<object class="GtkLabel">
<property name="hexpand">1</property>
<layout>
<property name="column">7</property>
<property name="column">8</property>
</layout>
</object>
</child>
+4 -29
View File
@@ -7,10 +7,6 @@
struct _ExampleAppPrefs
{
GtkDialog parent;
GSettings *settings;
GtkWidget *font;
GtkWidget *transition;
};
G_DEFINE_TYPE (ExampleAppPrefs, example_app_prefs, GTK_TYPE_DIALOG)
@@ -19,41 +15,20 @@ static void
example_app_prefs_init (ExampleAppPrefs *prefs)
{
gtk_widget_init_template (GTK_WIDGET (prefs));
prefs->settings = g_settings_new ("org.gtk.exampleapp");
g_settings_bind (prefs->settings, "font",
prefs->font, "font",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (prefs->settings, "transition",
prefs->transition, "active-id",
G_SETTINGS_BIND_DEFAULT);
}
static void
example_app_prefs_dispose (GObject *object)
{
ExampleAppPrefs *prefs;
prefs = EXAMPLE_APP_PREFS (object);
g_clear_object (&prefs->settings);
G_OBJECT_CLASS (example_app_prefs_parent_class)->dispose (object);
}
static void
example_app_prefs_class_init (ExampleAppPrefsClass *class)
{
G_OBJECT_CLASS (class)->dispose = example_app_prefs_dispose;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gtk/exampleapp/prefs.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, font);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), ExampleAppPrefs, transition);
}
ExampleAppPrefs *
example_app_prefs_new (ExampleAppWindow *win)
{
return g_object_new (EXAMPLE_APP_PREFS_TYPE, "transient-for", win, "use-header-bar", TRUE, NULL);
return g_object_new (EXAMPLE_APP_PREFS_TYPE,
"transient-for", win,
"use-header-bar", TRUE,
NULL);
}
+2
View File
@@ -28,6 +28,7 @@
</child>
<child>
<object class="GtkFontButton" id="font">
<property name="font" bind-settings-schema="org.gtk.exampleapp" bind-settings-key="font"/>
<layout>
<property name="column">1</property>
<property name="row">0</property>
@@ -48,6 +49,7 @@
</child>
<child>
<object class="GtkComboBoxText" id="transition">
<property name="active-id" bind-settings-schema="org.gtk.exampleapp" bind-settings-key="transition"/>
<items>
<item translatable="yes" id="none">None</item>
<item translatable="yes" id="crossfade">Fade</item>
-13
View File
@@ -492,19 +492,6 @@ GskRenderNode * gsk_text_node_new (PangoFont
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset);
GDK_AVAILABLE_IN_4_6
GskRenderNode * gsk_text_node_new_with_font_options (const cairo_font_options_t *options,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset);
GDK_AVAILABLE_IN_4_6
gboolean gsk_text_node_get_hint_metrics (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_6
gboolean gsk_text_node_get_antialias (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_4_6
cairo_hint_style_t gsk_text_node_get_hint_style (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
PangoFont * gsk_text_node_get_font (const GskRenderNode *node) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
+21 -149
View File
@@ -4336,10 +4336,7 @@ struct _GskTextNode
GskRenderNode render_node;
PangoFont *font;
guint has_color_glyphs : 1;
guint hint_metrics : 1;
guint antialias : 1;
guint hint_style : 3;
gboolean has_color_glyphs;
GdkRGBA color;
graphene_point_t offset;
@@ -4366,7 +4363,6 @@ gsk_text_node_draw (GskRenderNode *node,
{
GskTextNode *self = (GskTextNode *) node;
PangoGlyphString glyphs;
cairo_font_options_t *options;
glyphs.num_glyphs = self->num_glyphs;
glyphs.glyphs = self->glyphs;
@@ -4374,13 +4370,6 @@ gsk_text_node_draw (GskRenderNode *node,
cairo_save (cr);
options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (options, self->hint_metrics ? CAIRO_HINT_METRICS_ON : CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, self->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
cairo_font_options_set_hint_style (options, self->hint_style);
cairo_set_font_options (cr, options);
cairo_font_options_destroy (options);
gdk_cairo_set_source_rgba (cr, &self->color);
cairo_translate (cr, self->offset.x, self->offset.y);
pango_cairo_show_glyph_string (cr, self->font, &glyphs);
@@ -4388,15 +4377,6 @@ gsk_text_node_draw (GskRenderNode *node,
cairo_restore (cr);
}
/* We steal one of the bits in PangoGlyphVisAttr */
G_STATIC_ASSERT (sizeof (PangoGlyphVisAttr) == 4);
#define COLOR_GLYPH_BIT 2
#define GLYPH_IS_COLOR(g) (((*(guint32*)&(g)->attr) & COLOR_GLYPH_BIT) != 0)
#define GLYPH_SET_COLOR(g) (*(guint32*)(&(g)->attr) |= COLOR_GLYPH_BIT)
#define GLYPH_CLEAR_COLOR(g) (*(guint32*)(&(g)->attr) &= ~COLOR_GLYPH_BIT)
static void
gsk_text_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
@@ -4422,7 +4402,7 @@ gsk_text_node_diff (GskRenderNode *node1,
info1->geometry.x_offset == info2->geometry.x_offset &&
info1->geometry.y_offset == info2->geometry.y_offset &&
info1->attr.is_cluster_start == info2->attr.is_cluster_start &&
GLYPH_IS_COLOR (info1) == GLYPH_IS_COLOR (info2))
info1->attr.is_color == info2->attr.is_color)
continue;
gsk_render_node_diff_impossible (node1, node2, region);
@@ -4435,12 +4415,25 @@ gsk_text_node_diff (GskRenderNode *node1,
gsk_render_node_diff_impossible (node1, node2, region);
}
static GskRenderNode *
gsk_text_node_new_internal (const cairo_font_options_t *options,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset)
/**
* gsk_text_node_new:
* @font: the `PangoFont` containing the glyphs
* @glyphs: the `PangoGlyphString` to render
* @color: the foreground color to render with
* @offset: offset of the baseline
*
* Creates a render node that renders the given glyphs.
*
* Note that @color may not be used if the font contains
* color glyphs.
*
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
*/
GskRenderNode *
gsk_text_node_new (PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset)
{
GskTextNode *self;
GskRenderNode *node;
@@ -4462,16 +4455,6 @@ gsk_text_node_new_internal (const cairo_font_options_t *options,
self->color = *color;
self->offset = *offset;
self->has_color_glyphs = FALSE;
self->antialias = TRUE;
self->hint_style = CAIRO_HINT_STYLE_NONE;
self->hint_metrics = FALSE;
if (options)
{
self->antialias = cairo_font_options_get_antialias (options) != CAIRO_ANTIALIAS_NONE;
self->hint_metrics = cairo_font_options_get_hint_metrics (options) == CAIRO_HINT_METRICS_ON;
self->hint_style = cairo_font_options_get_hint_style (options);
}
glyph_infos = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
@@ -4502,117 +4485,6 @@ gsk_text_node_new_internal (const cairo_font_options_t *options,
return node;
}
/**
* gsk_text_node_new_with_font_options:
* @options: `cairo_font_options_t` to render with
* @font: the `PangoFont` containing the glyphs
* @glyphs: the `PangoGlyphString` to render
* @color: the foreground color to render with
* @offset: offset of the baseline
*
* Creates a render node that renders the given glyphs.
*
* Note that @color may not be used if the font contains
* color glyphs.
*
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
*
* Since: 4.6
*/
GskRenderNode *
gsk_text_node_new_with_font_options (const cairo_font_options_t *options,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset)
{
return gsk_text_node_new_internal (options, font, glyphs, color, offset);
}
/**
* gsk_text_node_new:
* @font: the `PangoFont` containing the glyphs
* @glyphs: the `PangoGlyphString` to render
* @color: the foreground color to render with
* @offset: offset of the baseline
*
* Creates a render node that renders the given glyphs.
*
* Note that @color may not be used if the font contains
* color glyphs.
*
* Returns: (nullable) (transfer full) (type GskTextNode): a new `GskRenderNode`
*/
GskRenderNode *
gsk_text_node_new (PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
const graphene_point_t *offset)
{
return gsk_text_node_new_internal (NULL, font, glyphs, color, offset);
}
/**
* gsk_text_node_get_hint_metrics:
* @node: (type GskTextNode): a text `GskRenderNode`
*
* Retrieves whether metrics hinting is enabled for rendering.
*
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-metrics-t).
*
* Returns: whether metrics hinting is enabled
*
* Since: 4.6
*/
gboolean
gsk_text_node_get_hint_metrics (const GskRenderNode *node)
{
const GskTextNode *self = (const GskTextNode *) node;
return self->hint_metrics;
}
/**
* gsk_text_node_get_antialias:
* @node: (type GskTextNode): a text `GskRenderNode`
*
* Retrieves whether antialiasing is enabled for rendering.
*
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t).
* Note that GSK only supports grayscale antialiasing.
*
* Returns: whether antialiasing is enabled
*
* Since: 4.6
*/
gboolean
gsk_text_node_get_antialias (const GskRenderNode *node)
{
const GskTextNode *self = (const GskTextNode *) node;
return self->antialias;
}
/**
* gsk_text_node_get_hint_style:
* @node: (type GskTextNode): a text `GskRenderNode`
*
* Retrieves what style of font hinting is used for rendering.
*
* See the cairo [documentation](https://www.cairographics.org/manual/cairo-cairo-font-options-t.html#cairo-hint-style-t).
*
* Returns: what style of hinting is used
*
* Since: 4.6
*/
cairo_hint_style_t
gsk_text_node_get_hint_style (const GskRenderNode *node)
{
const GskTextNode *self = (const GskTextNode *) node;
return self->hint_style;
}
/**
* gsk_text_node_get_color:
* @node: (type GskTextNode): a text `GskRenderNode`
-8
View File
@@ -166,19 +166,11 @@ render_glyph (cairo_surface_t *surface,
{
cairo_t *cr;
cairo_glyph_t glyph;
cairo_font_options_t *options;
g_assert (surface != NULL);
g_assert (scaled_font != NULL);
cr = cairo_create (surface);
options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (options, key->hint_metrics ? CAIRO_HINT_METRICS_ON : CAIRO_HINT_METRICS_OFF);
cairo_font_options_set_antialias (options, key->antialias ? CAIRO_ANTIALIAS_GRAY : CAIRO_ANTIALIAS_NONE);
cairo_font_options_set_hint_style (options, key->hint_style);
cairo_set_font_options (cr, options);
cairo_font_options_destroy (options);
cairo_set_scaled_font (cr, scaled_font);
cairo_set_source_rgba (cr, 1, 1, 1, 1);
+1 -4
View File
@@ -35,10 +35,7 @@ typedef struct _GskNglGlyphKey
PangoGlyph glyph;
guint xshift : 2;
guint yshift : 2;
guint hint_metrics : 1;
guint antialias : 1;
guint hint_style : 3;
guint scale : 23; /* times 1024 */
guint scale : 28; /* times 1024 */
} GskNglGlyphKey;
typedef struct _GskNglGlyphValue
-7
View File
@@ -2875,16 +2875,9 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
rgba_to_half (color, cc);
/* We have 23 bits in the key for the scale */
g_assert (text_scale * 1024 < (1 << 24));
lookup.font = (PangoFont *)font;
lookup.scale = (guint) (text_scale * 1024);
lookup.hint_metrics = gsk_text_node_get_hint_metrics (node);
lookup.antialias = gsk_text_node_get_antialias (node);
lookup.hint_style = gsk_text_node_get_hint_style (node);
yshift = compute_phase_and_pos (y, &ypos);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
-5
View File
@@ -100,7 +100,6 @@ gsk_pango_renderer_draw_glyph_item (PangoRenderer *renderer,
get_color (crenderer, PANGO_RENDER_PART_FOREGROUND, &color);
gtk_snapshot_append_text (crenderer->snapshot,
crenderer->options,
glyph_item->item->analysis.font,
glyph_item->glyphs,
&color,
@@ -468,18 +467,14 @@ gtk_snapshot_append_layout (GtkSnapshot *snapshot,
const GdkRGBA *color)
{
GskPangoRenderer *crenderer;
PangoContext *context;
g_return_if_fail (snapshot != NULL);
g_return_if_fail (PANGO_IS_LAYOUT (layout));
crenderer = gsk_pango_renderer_acquire ();
context = pango_layout_get_context (layout);
crenderer->snapshot = snapshot;
crenderer->fg_color = color;
crenderer->options = pango_cairo_context_get_font_options (context);
pango_renderer_draw_layout (PANGO_RENDERER (crenderer), layout, 0, 0);
-2
View File
@@ -63,8 +63,6 @@ struct _GskPangoRenderer
/* Error underline color for this widget */
GdkRGBA *error_color;
const cairo_font_options_t *options;
GskPangoRendererState state;
guint is_cached_renderer : 1;
+17 -6
View File
@@ -484,15 +484,26 @@ out:
*
* Parses a string representing an accelerator.
*
* The format looks like <Control>a or <Shift><Alt>F1.
* The format looks like `<Control>a` or `<Shift><Alt>F1`.
*
* The parser is fairly liberal and allows lower or upper case, and also
* abbreviations such as <Ctl> and <Ctrl>. Key names are parsed using
* [func@Gdk.keyval_from_name]. For character keys the name is not the symbol,
* but the lowercase name, e.g. one would use <Ctrl>minus instead of
* <Ctrl>-.
* abbreviations such as `<Ctl>` and `<Ctrl>`.
*
* If the parse fails, @accelerator_key and @accelerator_mods will
* Key names are parsed using [func@Gdk.keyval_from_name]. For character keys
* the name is not the symbol, but the lowercase name, e.g. one would use
* `<Ctrl>minus` instead of `<Ctrl>-`.
*
* Modifiers are enclosed in angular brackets `<>`, and match the
* [enum@Gdk.ModifierType] mask:
*
* - `<Shift>` for `GDK_SHIFT_MASK`
* - `<Ctrl>` for `GDK_CONTROL_MASK`
* - `<Alt>` for `GDK_ALT_MASK`
* - `<Meta>` for `GDK_META_MASK`
* - `<Super>` for `GDK_SUPER_MASK`
* - `<Hyper>` for `GDK_HYPER_MASK`
*
* If the parse operation fails, @accelerator_key and @accelerator_mods will
* be set to 0 (zero).
*/
gboolean
+50 -15
View File
@@ -65,6 +65,14 @@
* using `dgettext()` in the domain specified. This can also be done by
* calling [method@Gtk.Builder.set_translation_domain] on the builder.
*
* The target toolkit version(s) are described by `<requires>` elements,
* the lib attribute specifies the widget library in question (currently
* the only supported value is gtk) and the version attribute specifies
* the target version in the form `<major>`.`<minor>`. `GtkBuilder` will
* error out if the version requirements are not met.
*
* ### Objects
*
* Objects are described by `<object>` elements, which can contain
* `<property>` elements to set properties, `<signal>` elements which
* connect signals to handlers, and `<child>` elements, which describe
@@ -72,16 +80,10 @@
* actions in an action group, or columns in a tree model). A `<child>`
* element contains an `<object>` element which describes the child object.
*
* The target toolkit version(s) are described by `<requires>` elements,
* the lib attribute specifies the widget library in question (currently
* the only supported value is gtk) and the version attribute specifies
* the target version in the form `<major>`.`<minor>`. `GtkBuilder` will
* error out if the version requirements are not met.
*
* Typically, the specific kind of object represented by an `<object>`
* element is specified by the class attribute. If the type has not
* been loaded yet, GTK tries to find the `get_type()` function from the
* class name by applying heuristics. This works in most cases, but if
* class name by applying heuristics; this works in most cases, but if
* necessary, it is possible to specify the name of the `get_type()`
* function explicitly with the "type-func" attribute.
*
@@ -92,6 +94,8 @@
* reserves ids starting and ending with `___` (three consecutive
* underscores) for its own purposes.
*
* ### Properties and values
*
* Setting properties of objects is pretty straightforward with the
* `<property>` element: the name attribute specifies the name of the
* property, and the content of the element specifies the value.
@@ -125,12 +129,27 @@
* exception to this rule is that an object has to be constructed before
* it can be used as the value of a construct-only property.
*
* It is also possible to bind a property value to another object's
* ### Property bindings
*
* It is possible to bind a property value to another object's
* property value using the attributes "bind-source" to specify the
* source object of the binding, and optionally, "bind-property" and
* "bind-flags" to specify the source property and source binding flags
* respectively. Internally, `GtkBuilder` implements this using `GBinding`
* objects. For more information see g_object_bind_property().
* objects. For more information see the documentation for
* [method@GObject.Object.bind_property].
*
* ### Settings bindings
*
* It is possible to bind a property value to a [class@Gio.Settings] key
* inside a schema, by using the attributes "bind-settings-schema" to
* define the schema, and "bind-settings-key" to define the key. If either
* attribute is set, the other is mandatory. Additionally, you can use
* the "bind-flags" attribute to specify the [enum@Gio.SettingsBindFlags]
* to be used by the binding. For more information see the documentation
* for [method@Gio.Settings.bind].
*
* ### Internal children
*
* Sometimes it is necessary to refer to widgets which have implicitly
* been constructed by GTK as part of a composite widget, to set
@@ -146,7 +165,7 @@
* The possible values for the type attribute are described in the
* sections describing the widget-specific portions of UI definitions.
*
* # Signal handlers and function pointers
* ### Signal handlers and function pointers
*
* Signal handlers are set up with the `<signal>` element. The name
* attribute specifies the name of the signal, and the handler attribute
@@ -161,9 +180,9 @@
* the following details should be noted:
*
* When compiling applications for Windows, you must declare signal callbacks
* with %G_MODULE_EXPORT, or they will not be put in the symbol table.
* with `G_MODULE_EXPORT`, or they will not be put in the symbol table.
* On Linux and Unix, this is not necessary; applications should instead
* be compiled with the -Wl,--export-dynamic `CFLAGS`, and linked against
* be compiled with the `-Wl,--export-dynamic` `CFLAGS`, and linked against
* `gmodule-export-2.0`.
*
* # A GtkBuilder UI Definition
@@ -191,10 +210,10 @@
* ```
*
* Beyond this general structure, several object classes define their
* own XML DTD fragments for filling in the ANY placeholders in the DTD
* above. Note that a custom element in a <child> element gets parsed by
* own XML DTD fragments for filling in the `ANY` placeholders in the DTD
* above. Note that a custom element in a `<child>` element gets parsed by
* the custom tag handler of the parent object, while a custom element in
* an <object> element gets parsed by the custom tag handler of the object.
* an `<object>` element gets parsed by the custom tag handler of the object.
*
* These XML fragments are explained in the documentation of the
* respective objects.
@@ -719,6 +738,11 @@ gtk_builder_take_bindings (GtkBuilder *builder,
BindingExpressionInfo *info = l->data;
info->target = target;
}
else if (common_info->tag_type == TAG_BINDING_SETTING)
{
BindingSettingsInfo *info = l->data;
info->target = target;
}
else
{
g_assert_not_reached ();
@@ -1146,6 +1170,17 @@ gtk_builder_create_bindings (GtkBuilder *builder,
free_binding_expression_info (info);
}
else if (common_info->tag_type == TAG_BINDING_SETTING)
{
BindingSettingsInfo *info = l->data;
GSettings *settings;
settings = g_settings_new (info->schema);
g_settings_bind (settings, info->key, info->target, info->target_pspec->name, info->flags);
g_object_unref (settings);
free_binding_settings_info (info);
}
else
g_assert_not_reached ();
}
+66 -10
View File
@@ -874,7 +874,8 @@ parse_property (ParserData *data,
const char *bind_source = NULL;
const char *bind_property = NULL;
const char *bind_flags_str = NULL;
GBindingFlags bind_flags = G_BINDING_DEFAULT;
const char *bind_schema = NULL;
const char *bind_key = NULL;
gboolean translatable = FALSE;
ObjectInfo *object_info;
GParamSpec *pspec = NULL;
@@ -897,6 +898,8 @@ parse_property (ParserData *data,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-source", &bind_source,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-property", &bind_property,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-flags", &bind_flags_str,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-settings-schema", &bind_schema,
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "bind-settings-key", &bind_key,
G_MARKUP_COLLECT_INVALID))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
@@ -916,21 +919,59 @@ parse_property (ParserData *data,
return;
}
if (bind_flags_str)
gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
if (bind_schema != NULL)
{
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error))
GSettingsBindFlags bind_flags = G_SETTINGS_BIND_DEFAULT;
if (bind_flags_str)
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
if (!_gtk_builder_flags_from_string (G_TYPE_SETTINGS_BIND_FLAGS, NULL, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;
}
}
if (bind_key != NULL)
{
BindingSettingsInfo *binfo;
binfo = g_slice_new0 (BindingSettingsInfo);
binfo->tag_type = TAG_BINDING_SETTING;
binfo->target = NULL;
binfo->target_pspec = pspec;
binfo->schema = g_strdup (bind_schema);
binfo->key = g_strdup (bind_key);
binfo->flags = bind_flags;
binfo->line = line;
binfo->col = col;
object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
}
else
{
error_missing_attribute (data, element_name,
"bind-settings-key",
error);
return;
}
}
gtk_buildable_parse_context_get_position (&data->ctx, &line, &col);
if (bind_source)
else if (bind_source != NULL)
{
GBindingFlags bind_flags = G_BINDING_DEFAULT;
BindingInfo *binfo;
if (bind_flags_str)
{
if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, NULL, bind_flags_str, &bind_flags, error))
{
_gtk_builder_prefix_error (data->builder, &data->ctx, error);
return;
}
}
binfo = g_slice_new0 (BindingInfo);
binfo->tag_type = TAG_BINDING;
binfo->target = NULL;
@@ -943,7 +984,14 @@ parse_property (ParserData *data,
object_info->bindings = g_slist_prepend (object_info->bindings, binfo);
}
else if (bind_property)
else if (bind_key != NULL)
{
error_missing_attribute (data, element_name,
"bind-settings-schema",
error);
return;
}
else if (bind_property != NULL)
{
error_missing_attribute (data, element_name,
"bind-source",
@@ -956,7 +1004,7 @@ parse_property (ParserData *data,
info->pspec = pspec;
info->text = g_string_new ("");
info->translatable = translatable;
info->bound = bind_source != NULL;
info->bound = bind_source != NULL || bind_schema != NULL;
info->context = g_strdup (context);
info->line = line;
info->col = col;
@@ -1563,6 +1611,14 @@ free_binding_expression_info (BindingExpressionInfo *info)
g_slice_free (BindingExpressionInfo, info);
}
void
free_binding_settings_info (BindingSettingsInfo *info)
{
g_free (info->schema);
g_free (info->key);
g_slice_free (BindingSettingsInfo, info);
}
static void
free_requires_info (RequiresInfo *info,
gpointer user_data)
+14
View File
@@ -27,6 +27,7 @@ enum {
TAG_PROPERTY,
TAG_BINDING,
TAG_BINDING_EXPRESSION,
TAG_BINDING_SETTING,
TAG_REQUIRES,
TAG_OBJECT,
TAG_CHILD,
@@ -141,6 +142,18 @@ typedef struct
int col;
} BindingExpressionInfo;
typedef struct
{
guint tag_type;
GObject *target;
GParamSpec *target_pspec;
char *schema;
char *key;
GSettingsBindFlags flags;
int line;
int col;
} BindingSettingsInfo;
typedef struct {
guint tag_type;
char *library;
@@ -228,6 +241,7 @@ void _free_signal_info (SignalInfo *info,
void _free_binding_info (BindingInfo *info,
gpointer user_data);
void free_binding_expression_info (BindingExpressionInfo *info);
void free_binding_settings_info (BindingSettingsInfo *info);
GtkExpression * expression_info_construct (GtkBuilder *builder,
ExpressionInfo *info,
GError **error);
+10 -12
View File
@@ -2121,24 +2121,22 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
}
void
gtk_snapshot_append_text (GtkSnapshot *snapshot,
const cairo_font_options_t *options,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
float x,
float y)
gtk_snapshot_append_text (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
float x,
float y)
{
GskRenderNode *node;
float dx, dy;
gtk_snapshot_ensure_translate (snapshot, &dx, &dy);
node = gsk_text_node_new_with_font_options (options,
font,
glyphs,
color,
&GRAPHENE_POINT_INIT (x + dx, y + dy));
node = gsk_text_node_new (font,
glyphs,
color,
&GRAPHENE_POINT_INIT (x + dx, y + dy));
if (node == NULL)
return;
+6 -7
View File
@@ -24,13 +24,12 @@
G_BEGIN_DECLS
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
const cairo_font_options_t *options,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
float x,
float y);
void gtk_snapshot_append_text (GtkSnapshot *snapshot,
PangoFont *font,
PangoGlyphString *glyphs,
const GdkRGBA *color,
float x,
float y);
void gtk_snapshot_push_collect (GtkSnapshot *snapshot);
GskRenderNode * gtk_snapshot_pop_collect (GtkSnapshot *snapshot);
+50 -14
View File
@@ -397,6 +397,8 @@ static void gtk_text_view_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_text_view_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static void gtk_text_view_system_setting_changed (GtkWidget *widget,
GtkSystemSetting setting);
static void gtk_text_view_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
@@ -573,6 +575,7 @@ static void gtk_text_view_update_im_spot_location (GtkTextView *text_view);
static void gtk_text_view_insert_emoji (GtkTextView *text_view);
static void update_node_ordering (GtkWidget *widget);
static void gtk_text_view_update_pango_contexts (GtkTextView *text_view);
/* GtkTextHandle handlers */
static void gtk_text_view_handle_drag_started (GtkTextHandle *handle,
@@ -819,6 +822,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->map = gtk_text_view_map;
widget_class->css_changed = gtk_text_view_css_changed;
widget_class->direction_changed = gtk_text_view_direction_changed;
widget_class->system_setting_changed = gtk_text_view_system_setting_changed;
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
widget_class->measure = gtk_text_view_measure;
widget_class->size_allocate = gtk_text_view_size_allocate;
@@ -4984,7 +4988,6 @@ gtk_text_view_css_changed (GtkWidget *widget,
{
GtkTextView *text_view;
GtkTextViewPrivate *priv;
PangoContext *ltr_context, *rtl_context;
text_view = GTK_TEXT_VIEW (widget);
priv = text_view->priv;
@@ -5001,16 +5004,13 @@ gtk_text_view_css_changed (GtkWidget *widget,
gtk_text_view_set_attributes_from_style (text_view,
priv->layout->default_style);
gtk_text_layout_default_style_changed (priv->layout);
}
ltr_context = gtk_widget_create_pango_context (widget);
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
rtl_context = gtk_widget_create_pango_context (widget);
pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
g_object_unref (ltr_context);
g_object_unref (rtl_context);
if ((change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT)) &&
priv->layout)
{
gtk_text_view_update_pango_contexts (text_view);
}
}
@@ -5028,6 +5028,42 @@ gtk_text_view_direction_changed (GtkWidget *widget,
}
}
static void
gtk_text_view_update_pango_contexts (GtkTextView *text_view)
{
GtkWidget *widget = GTK_WIDGET (text_view);
GtkTextViewPrivate *priv = text_view->priv;
gboolean update_ltr, update_rtl;
if (!priv->layout)
return;
update_ltr = gtk_widget_update_pango_context (widget, priv->layout->ltr_context, GTK_TEXT_DIR_LTR);
update_rtl = gtk_widget_update_pango_context (widget, priv->layout->rtl_context, GTK_TEXT_DIR_RTL);
if (update_ltr || update_rtl)
{
GtkTextIter start, end;
gtk_text_buffer_get_bounds (get_buffer (text_view), &start, &end);
gtk_text_layout_invalidate (priv->layout, &start, &end);
gtk_widget_queue_draw (widget);
}
}
static void
gtk_text_view_system_setting_changed (GtkWidget *widget,
GtkSystemSetting setting)
{
if (setting == GTK_SYSTEM_SETTING_DPI ||
setting == GTK_SYSTEM_SETTING_FONT_NAME ||
setting == GTK_SYSTEM_SETTING_FONT_CONFIG)
{
gtk_text_view_update_pango_contexts (GTK_TEXT_VIEW (widget));
}
}
static void
gtk_text_view_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state)
@@ -7809,8 +7845,8 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
if (priv->layout == NULL)
{
GtkTextAttributes *style;
PangoContext *ltr_context, *rtl_context;
const GList *iter;
PangoContext *ltr_context, *rtl_context;
DV(g_print(G_STRLOC"\n"));
@@ -7843,15 +7879,15 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
priv->overwrite_mode && priv->editable);
ltr_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
rtl_context = gtk_widget_create_pango_context (GTK_WIDGET (text_view));
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
pango_context_set_base_dir (rtl_context, PANGO_DIRECTION_RTL);
gtk_text_layout_set_contexts (priv->layout, ltr_context, rtl_context);
g_object_unref (ltr_context);
g_object_unref (rtl_context);
gtk_text_view_update_pango_contexts (text_view);
gtk_text_view_check_keymap_direction (text_view);
style = gtk_text_attributes_new ();
+19 -17
View File
@@ -572,7 +572,7 @@ static void gtk_widget_pop_verify_invariants (GtkWidget
#define gtk_widget_pop_verify_invariants(widget)
#endif
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_update_pango_context (GtkWidget *widget);
static void gtk_widget_update_default_pango_context (GtkWidget *widget);
static void gtk_widget_propagate_state (GtkWidget *widget,
const GtkStateData *data);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
@@ -4957,7 +4957,7 @@ gtk_widget_real_css_changed (GtkWidget *widget,
const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
if (has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT))
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
if (priv->root)
{
@@ -4980,7 +4980,7 @@ gtk_widget_real_css_changed (GtkWidget *widget,
}
else
{
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
if (priv->root)
gtk_widget_queue_resize (widget);
@@ -4997,7 +4997,7 @@ gtk_widget_real_system_setting_changed (GtkWidget *widget,
setting == GTK_SYSTEM_SETTING_FONT_NAME ||
setting == GTK_SYSTEM_SETTING_FONT_CONFIG)
{
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
if (gtk_widget_peek_pango_context (widget))
gtk_widget_queue_resize (widget);
}
@@ -6427,9 +6427,10 @@ gtk_widget_get_effective_font_map (GtkWidget *widget)
return pango_cairo_font_map_get_default ();
}
static gboolean
update_pango_context (GtkWidget *widget,
PangoContext *context)
gboolean
gtk_widget_update_pango_context (GtkWidget *widget,
PangoContext *context,
GtkTextDirection direction)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkCssStyle *style = gtk_css_node_get_style (priv->cssnode);
@@ -6455,9 +6456,10 @@ update_pango_context (GtkWidget *widget,
pango_context_set_round_glyph_positions (context, hint_font_metrics);
}
pango_context_set_base_dir (context,
_gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
if (direction != GTK_TEXT_DIR_NONE)
pango_context_set_base_dir (context, direction == GTK_TEXT_DIR_LTR
? PANGO_DIRECTION_LTR
: PANGO_DIRECTION_RTL);
pango_cairo_context_set_resolution (context, _gtk_css_number_value_get (style->core->dpi, 100));
@@ -6483,14 +6485,14 @@ update_pango_context (GtkWidget *widget,
}
static void
gtk_widget_update_pango_context (GtkWidget *widget)
gtk_widget_update_default_pango_context (GtkWidget *widget)
{
PangoContext *context = gtk_widget_peek_pango_context (widget);
if (!context)
return;
if (update_pango_context (widget, context))
if (gtk_widget_update_pango_context (widget, context, _gtk_widget_get_direction (widget)))
gtk_widget_queue_draw (widget);
}
@@ -6522,7 +6524,7 @@ gtk_widget_set_font_options (GtkWidget *widget,
options ? cairo_font_options_copy (options) : NULL,
(GDestroyNotify)cairo_font_options_destroy);
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
}
}
@@ -6551,7 +6553,7 @@ gtk_widget_set_font_map_recurse (GtkWidget *widget, gpointer user_data)
if (g_object_get_qdata (G_OBJECT (widget), quark_font_map))
return;
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, user_data);
}
@@ -6588,7 +6590,7 @@ gtk_widget_set_font_map (GtkWidget *widget,
g_object_ref (font_map),
g_object_unref);
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
gtk_widget_forall (widget, gtk_widget_set_font_map_recurse, NULL);
}
@@ -6631,7 +6633,7 @@ gtk_widget_create_pango_context (GtkWidget *widget)
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
update_pango_context (widget, context);
gtk_widget_update_pango_context (widget, context, _gtk_widget_get_direction (widget));
pango_context_set_language (context, gtk_get_default_language ());
return context;
@@ -7216,7 +7218,7 @@ gtk_widget_emit_direction_changed (GtkWidget *widget,
GtkTextDirection direction;
GtkStateFlags state;
gtk_widget_update_pango_context (widget);
gtk_widget_update_default_pango_context (widget);
direction = _gtk_widget_get_direction (widget);
+4
View File
@@ -370,6 +370,10 @@ void gtk_widget_update_orientation (GtkWidget *widget,
void gtk_widget_realize_at_context (GtkWidget *widget);
void gtk_widget_unrealize_at_context (GtkWidget *widget);
gboolean gtk_widget_update_pango_context (GtkWidget *widget,
PangoContext *context,
GtkTextDirection direction);
/* inline getters */
static inline GtkWidget *
+40 -28
View File
@@ -1,29 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="gtk40">
<object class="GtkAdjustment" id="scale_adjustment">
<property name="lower">1</property>
<property name="upper">3</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
<object class="GtkAdjustment" id="font_scale_adjustment">
<property name="lower">0.5</property>
<property name="upper">2</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.01</property>
</object>
<object class="GtkAdjustment" id="slowdown_adjustment">
<property name="lower">-3</property>
<property name="upper">3</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
<object class="GtkAdjustment" id="cursor_size_adjustment">
<property name="lower">16</property>
<property name="upper">128</property>
<property name="step-increment">8</property>
<property name="page-increment">8</property>
</object>
<template class="GtkInspectorVisual" parent="GtkWidget">
<child>
<object class="GtkScrolledWindow" id="swin">
@@ -142,7 +118,14 @@
<property name="valign">baseline</property>
<property name="max-width-chars">2</property>
<property name="width-chars">2</property>
<property name="adjustment">cursor_size_adjustment</property>
<property name="adjustment">
<object class="GtkAdjustment" id="cursor_size_adjustment">
<property name="lower">16</property>
<property name="upper">128</property>
<property name="step-increment">8</property>
<property name="page-increment">8</property>
</object>
</property>
<property name="snap-to-ticks">1</property>
<property name="hexpand">1</property>
</object>
@@ -218,7 +201,14 @@
<child>
<object class="GtkScale" id="font_scale_scale">
<property name="valign">baseline</property>
<property name="adjustment">font_scale_adjustment</property>
<property name="adjustment">
<object class="GtkAdjustment" id="font_scale_adjustment">
<property name="lower">0.5</property>
<property name="upper">2</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.01</property>
</object>
</property>
<property name="draw-value">0</property>
<property name="hexpand">1</property>
<marks>
@@ -231,6 +221,7 @@
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="width-chars">4</property>
<property name="max-width-chars">4</property>
<property name="input-purpose">number</property>
</object>
</child>
@@ -290,7 +281,14 @@
<object class="GtkSpinButton" id="hidpi_spin">
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="adjustment">scale_adjustment</property>
<property name="adjustment">
<object class="GtkAdjustment" id="scale_adjustment">
<property name="lower">1</property>
<property name="upper">3</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
</property>
<property name="snap-to-ticks">1</property>
<property name="hexpand">1</property>
</object>
@@ -339,7 +337,14 @@
</child>
<child>
<object class="GtkScale" id="slowdown_scale">
<property name="adjustment">slowdown_adjustment</property>
<property name="adjustment">
<object class="GtkAdjustment" id="slowdown_adjustment">
<property name="lower">-3</property>
<property name="upper">3</property>
<property name="step-increment">1</property>
<property name="page-increment">1</property>
</object>
</property>
<property name="valign">baseline</property>
<property name="draw-value">0</property>
<property name="hexpand">1</property>
@@ -353,6 +358,7 @@
<property name="halign">end</property>
<property name="valign">baseline</property>
<property name="width-chars">4</property>
<property name="max-width-chars">4</property>
<property name="input-purpose">number</property>
</object>
</child>
@@ -718,6 +724,12 @@
<widget name="software_gl_label"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<widgets>
<widget name="font_scale_label"/>
<widget name="slowdown_label"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<widgets>
<widget name="theme_combo"/>
+1 -1
View File
@@ -11,7 +11,7 @@ project('gtk', 'c',
license: 'LGPL-2.1-or-later')
glib_req = '>= 2.66.0'
pango_req = '>= 1.49.0' # keep this in sync with .gitlab-ci/test-msys.sh
pango_req = '>= 1.49.1' # keep this in sync with .gitlab-ci/test-msys.sh
fribidi_req = '>= 0.19.7'
cairo_req = '>= 1.14.0'
gdk_pixbuf_req = '>= 2.30.0'
+908 -804
View File
File diff suppressed because it is too large Load Diff
+1382 -1360
View File
File diff suppressed because it is too large Load Diff
+1740 -1734
View File
File diff suppressed because it is too large Load Diff
+549 -537
View File
File diff suppressed because it is too large Load Diff
+1778 -1746
View File
File diff suppressed because it is too large Load Diff
+3156 -3679
View File
File diff suppressed because it is too large Load Diff
+1136 -1049
View File
File diff suppressed because it is too large Load Diff
+357 -345
View File
File diff suppressed because it is too large Load Diff
+4033 -3303
View File
File diff suppressed because it is too large Load Diff
+514 -468
View File
File diff suppressed because it is too large Load Diff
+589 -543
View File
File diff suppressed because it is too large Load Diff
+2173 -1412
View File
File diff suppressed because it is too large Load Diff