Commit Graph

188 Commits

Author SHA1 Message Date
Benjamin Otte
ad3ded7ba0 textview: Add missing break statement 2019-04-15 14:38:23 +02:00
Benjamin Otte
720fd2cd40 textview: Fix comparison thinko
Apparently, we have no test that checks for actually drawing text, so
the thinko that caused all text to disappear in
4b07d28153 went unnoticed.
2019-03-31 20:22:05 +02:00
Benjamin Otte
4b07d28153 textlayout: Allow querying empty areas
This only happens when the textview has no content, but it does happen
now that such a textview gets allocated 0x0 and not 1x1.
2019-03-29 09:56:52 +01:00
Daniel Boles
db4895fbe5 TextLayout: Clarify implementation of special case
This exists to exit early for invisible lines. It attempts to use the
LineDisplay’s direction to create a corresponding PangoLayout. However,
the dir is not yet set by this point, & the display was new0()d, so its
dir is always 0 == TEXT_DIR_NONE. Thus, we always create an LTR layout.

Whatever the original intent, this outcome seems to be OK, so let’s make
the code say what it means, rather than using a misleading conditional.

https://bugzilla.gnome.org/show_bug.cgi?id=779099
2018-02-17 22:18:13 -05:00
Matthias Clasen
0b39631464 textview: Replace pixbufs by textures
This affects a few apis, such as gtk_text_iter_get_pixbuf,
gtk_text_buffer_insert_pixbuf and GtkTextBuffer::insert-pixbuf,
which have all been replaced by texture equivalents.

Update all callers.
2017-11-29 23:22:13 -05:00
Daniel Boles
7c2e28c8c5 doc: TextLayout: Add missing (out) annotations
and move from (allow-none) to (optional)
2017-11-22 20:48:11 +00:00
Matthias Clasen
a8531605db Some more interning
This avoids more strdups at startup.
2017-11-18 08:18:11 -05:00
Benjamin Otte
17600b6bab textview: Make the semi-private headrs really private
Rename the files to have the private.h ending.

And remove gtktextdisplay.h from the installed files.
2017-11-11 05:01:31 +01:00
Matthias Clasen
5b8b892dd6 textview: Fix memory handling
When cleaning up the text appearance struct, we forgot
to add the new strikethrough_rgba member to the copy
function.
2017-10-06 23:06:52 -04:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Matthias Clasen
6e178aede2 Use GdkRGBA for text attributes
Now that GtkTextAttributes is private, we can clean this struct
up a bit. The first step is to switch from GdkColor to GdkRGBA,
and adapt all users.
2016-11-01 13:58:10 -04:00
Timm Bäder
a5867ffe71 Remove some more GdkColor properties 2016-10-20 20:12:08 +02:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Benjamin Otte
45dfdbce3f textview: Track differences between ink and logical rects
This way, we can ensure that we queue redraws on the full ink rect. This
is particularly visible for squiggly underlines in spell checking.

https://bugzilla.gnome.org/show_bug.cgi?id=763741
2016-03-21 13:26:57 -04:00
Matthias Clasen
a3a5cf1087 text view: Improve tag pointer tracking
A problem that has been observed in polari is that links in tags
are clickable all the way into the margin. This problem is caused
by gtk_text_view_get_iter_at_position ignoring the return value
of pango_layout_xy_to_index. Instead, pass it back as a boolean
return value. This is technically an API break, but we've allowed
ourselves to change return types from void to gboolean before.
2016-02-10 00:01:54 -05:00
Matthias Clasen
55bd936b73 Don't use g_slist_next in gtktextlayout.c
We generally use ->next directly.
2015-10-20 06:14:57 -04:00
Matthias Clasen
c264cd6785 Split off a private header for GtkTextBuffer
This avoids polluting the installed header with private symbols.
2015-10-15 23:04:44 -04:00
Sebastien Lafargue
d1381569fd text view: add padding and margin
Add API to set top and bottom margins, and add the CSS padding
from the theme to the programmatically set margins.

https://bugzilla.gnome.org/show_bug.cgi?id=406159
2015-08-17 01:40:32 -04:00
Matthias Clasen
c6838fbff0 GtkTextView: Support font features
Add a ::font-features attribute to GtkTextTag, and support
font features when inserting Pango markup into a text buffer.
2015-07-29 21:42:58 -04:00
Matthias Clasen
02e2f7dc56 Fix a cornercase crash
If gtk_text_layout_move_cursor_visually is called with a
count of 0, we were passing NULL to a free function that
can't handle it. Don't do that.

https://bugzilla.gnome.org/show_bug.cgi?id=750058
2015-05-28 23:42:14 -04:00
Christian Hergert
28063ee2e4 textview: add support for underline and strikethrough colors
This commit adds the GtkTextTag:underline-rgba and :strikethrough-rgba
properties and the necessary plumbing to apply these colors in GtkTextLayout.
With this change, you can alter the color of underlines including those
of type PANGO_UNDERLINE_ERROR.

You might want to alter the underline color to differentiate between
spelling and grammer mistakes. In code editors, it is convenient to
differentiate between errors and warnings.

Note that the GtkTextAppearance struct is public ABI and has no spare
room for new fields, so we are resorting to some tricky packing to store
the colors in the unused pixel field of the fg_color and bg_color structs.
This packing is accomplished by the macros in gtktextattributesprivate.h.

Signed-off-by: Christian Hergert <christian@hergert.me>

https://bugzilla.gnome.org/show_bug.cgi?id=402168
2015-03-17 23:24:13 -04:00
Sebastien Lafargue
ce8dc51861 gtktextlayout: fix to quiet a warning
Gcc complains about a possible use of a not initialised
widget ref ( which can't happen in reality )

https://bugzilla.gnome.org/show_bug.cgi?id=741702
2014-12-18 21:00:45 +01:00
Sebastien Lafargue
73c8f30928 gtktextlayout: fix for right margin with RTL text
When a RTL paragraph is not set to wrap, the right margin is not respected
because of the margins counted twice so we replace
display->width by PIXEL_BOUND (extents.width), the same quantity
without the margins.

https://bugzilla.gnome.org/show_bug.cgi?id=741702
2014-12-18 20:52:58 +01:00
Matthias Clasen
d184088cae GtkTextView: Add fallback and letter-spacing support
Add support for the Pango attributes controlling font fallback
and letter spacing to GtkTextTag.

https://bugzilla.gnome.org/show_bug.cgi?id=740954
2014-12-04 00:09:44 -05:00
Sébastien Wilmet
9527205291 GtkTextView: use GSlice
GSlice is better for allocating structs.

https://bugzilla.gnome.org/show_bug.cgi?id=733407
2014-07-20 12:26:01 +02:00
Matthias Clasen
49cf5142ba Deprecate GdkColor
It has been replaced by GdkRGBA. Time to make it official.
http://bugzilla.gnome.org/show_bug.cgi?id=636695
2014-05-22 09:09:55 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Daiki Ueno
837a0d3e40 textlayout: avoid double-free when adding preedit color
In add_preedit_attrs, don't free foreground/background colors already
set in the underlying text attributes (style).  They will be free'd by
release_style.

https://bugzilla.gnome.org/show_bug.cgi?id=703533
2013-07-09 13:21:17 +09:00
Matthias Clasen
111cc604f5 Remove an unused private function
_gtk_text_layout_get_line_xrange was not exported and not used
inside GTK+ either.
2013-05-05 15:38:46 -04:00
Daiki Ueno
7a9553cfb5 textlayout: respect preedit color attribute
gtk_text_renderer_prepare_run now checks appearance.rgba, rather than
appearance.{fg_color,bg_color}.

https://bugzilla.gnome.org/show_bug.cgi?id=692766
2013-01-31 11:22:06 +09:00
Alexander Larsson
2422c44f8e Add custom va_marshallers in some places
This is a slight performance optimization in the common case.
2012-03-05 12:39:09 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Ignacio Casal Quinteiro
1abf7618c0 gtktextlayout: use g_slice for GtkTextLineDisplay 2011-12-25 18:13:51 +01:00
Ignacio Casal Quinteiro
69fba5d3ed textlayout: cleanup
Use g_clear_object, move unrefs to dispose and reorganize code
2011-12-18 18:46:36 +01:00
Paolo Borelli
397cbbef32 Use gtk_text_layout_get_iter_at_line
We already have a gtk_text_layout_get_iter_at_line wrapper that takes
care of getting the btree from the layout, we may as well use it.
2011-12-18 17:44:23 +01:00
Paolo Borelli
7f301cf822 Remove useless get_iter_at_line calls.
No need to call _gtk_text_btree_get_iter_at_line right before calling
totally_invisible_line, since it is the first thing it does itself.
2011-12-18 17:35:08 +01:00
Paolo Borelli
0bff1af7a2 Rework GtkTextView cursor code.
Move the handling of primary/secondary cursors to gtktextdisplay, which
makes code simpler and more consistent to how GtkLabel and GtkEntry
draw cursors, which is useful in preparation to further refactoring.

https://bugzilla.gnome.org/show_bug.cgi?id=640317
2011-12-01 01:22:39 +01:00
Tristan Van Berkom
cefb950110 Added internal GdkRGBA support for GtkTextTag::paragraph-background-rgba
Added the remaining implementation bits for rendering paragraph backgrounds
with rgba values and updated the test case.
2011-05-06 17:05:34 -04:00
Tristan Van Berkom
d399a4acab Added GdkRGBA properties to GtkTextTag.
This now allows text view to render text with alpha values in
the text foreground and backgrounds, the work is almost complete,
currently the error-underline-color is still a GdkColor style property
and since we use only GdkRGBA for rendering it needs to be converted
and applied, probably a new rgba version of the style property should
also be introduced.

This commit adds tests/testtextview that must be run from the tests/
directory to show translucent text in action.
2011-05-06 17:05:10 -04:00
Javier Jardón
55016f72f2 gtktexttag: Move public members to private header
And fix gail to not poke at GtkTextTag internals
2011-01-03 15:05:46 -05:00
Paolo Borelli
5e90bb269d Get rid of unused shaped_object list in _GtkTextLineDisplay
https://bugzilla.gnome.org/show_bug.cgi?id=631076
2010-11-02 12:04:37 +09:00
Matthias Clasen
f53ad33994 Remove GtkObject completely 2010-09-26 22:18:19 -04:00
Benjamin Otte
d9c9259861 Move GtkSizeRequest into GtkWidget
It doesn't make sense to keep them separate as GtkSizeRequest requires a
GtkWidget and GtkWidget implements GtkSizeRequest, so you can never have
one without the other.
It also makes the code a lot easier because no casts are required when
calling functions.

Also, the names would translate to gtk_widget_get_width() and people
agreed that this would be a too generic name, so a "preferred" was added
to the names.

So this patch moves the functions:
gtk_size_request_get_request_mode() => gtk_widget_get_request_mode()
gtk_size_request_get_width() => gtk_widget_get_preferred_width()
gtk_size_request_get_height() => gtk_widget_get_preferred_height()
gtk_size_request_get_size() => gtk_widget_get_preferred_size()
gtk_size_request_get_width_for_height() =>
  gtk_widget_get_preferred_width_for_height()
gtk_size_request_get_height_for_width() =>
  gtk_widget_get_preferred_height_for_width()
... and moves the corresponding vfuncs to the GtkWidgetClass.

The patch also renames the implementations of the vfuncs in widgets to
include the word "preferrred".
2010-09-26 15:11:45 +02:00
Javier Jardón
9e81022bf6 Use gtk_size_request_get_size() instead deprecated gtk_widget_get_child_requisition()
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=629177
2010-09-13 21:26:01 +02:00
Tor Lillqvist
87141cf4c8 Get rid of the rest of variables exported from libgtk
Especially the gtk_*_type ones in gtktexttypes.h were mentioned in
gtk.symbols presumably by accident. That header isn't even installed,
so no way can they be supposed to be public.

gtk_text_attr_appearance_type is from the installed but "semi-private"
gtktextlayout.h, so drop that one too from gtk.symbols for now.

The use of gtk_text_unknown_char_utf8 is bit of a mess. Code in a few
files knew implicitly that it is three bytes. Define a symbolic name
for the length of it instead. Add an exported function
gtk_text_unknown_char_utf8_gtk_tests_only() that returns a pointer to
it just for the sake of gtk/tests/textbuffer.c. Prefix the variable
with an underscore.

I doubt the usefulness of the test_utf8() in textbuffer.c. If it could
be dropped, gtk_text_unknown_char_utf8_gtk_tests_only() could be
dropped, too.
2010-09-08 21:31:34 +03:00
Benjamin Otte
9f1939cbd5 API: Remove GtkTextTag's stipple properties
They seem pretty much unused and the only reason why GtkTextView uses a
GdkPangoRenderer and not a PangoCairoRenderer.
2010-08-10 21:02:28 +02:00
Javier Jardón
0a07e9733b gtk/: fully remove gtkalias hacks
https://bugzilla.gnome.org/show_bug.cgi?id=623845
2010-07-10 02:51:26 +02:00