Commit Graph

888 Commits

Author SHA1 Message Date
Sebastian Dröge
ec1a48e830 Fix event type annotation on GtkEntry::icon-press / icon-release
This is not only a GdkEventButton but can also be a GdkEventTouch.
Having this annotation wrong causes bindings code to fail whenever a
wrongly typed event comes through.
2020-09-03 09:36:00 +03:00
Mohammed Sadiq
cadd794d2c entry: Restrict magnifier popover within the entry size
The magnifier shown with touch input should not go beyond the widget
limits.
2020-07-12 06:37:09 +05:30
Mohammed Sadiq
c823a4d673 entry: Always show 'select-all' button on touch popup
On touch, the popup shown shall contain the 'select-all' button
only if a selection is in progress and if the entry is editable.
Let the button be shown always if selectable so that it’s more helpful.
2020-05-07 18:09:40 +05:30
Carlos Garcia Campos
c6e5030c61 emojichooser: never show emoji chooser when input hint no-emoji is present
It's currently used only to not include the insert emoji option in the
context menu, but it's still possible to show the emoji chooser in both
GtkEntry and GtkTextView using the key bindings.
See also https://bugs.webkit.org/show_bug.cgi?id=205609.
2019-12-30 10:56:06 +01:00
Julian Sparber
ac39847187 GtkEntry: Make GtkEntry: gtk_entry_grab_focus_without_selecting () behave like gtk_widget_grab_focus ()
Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2204
2019-10-17 14:32:24 +02:00
Robert Mader
77e0d83000 gtk: Properly calculate device offset for DnD
We need to take the device scale into account, like it is done in
gdkwindow.c.

This fixes wrongly placed DnD surfaces in scaled contexts on X11
as well as Wayland.
2019-09-23 11:50:05 +02:00
Matthias Clasen
7b2c731fae entry: Use a better icon for Caps Lock warning
Use the same icon we use in master now.
2019-03-15 18:57:46 -04:00
Matthias Clasen
a3f1e02b9b gtk: Stop using deprecated pango api 2019-01-31 14:07:28 -05:00
Andrea Azzarone
2e24349fc6 entry: Handle no-window events in gtk_entry_event
gtk_entry_event's goal is to detect if a specific event concerns one of the two
entry icons. It can happen that this function is called during initialization
and/or before the entry is realized. In this case the entry icons (and the
event) will not yet have an associated window. The code should consider the
aforementioned situation and avoid matching a icon and an event with no
associated windows.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/1366
2018-09-27 14:19:34 +02:00
Matthias Clasen
09e3529d0e entry: Add emoji completion
Pop up completions when the text in the entry matches :word:
This functionality has to be enabled using the enable-emoji-completion
property.
2018-06-03 09:43:28 -04:00
Matthias Clasen
7e9ae85dd4 Export some entry functions privately
This will be used in the following commits.
2018-06-03 09:43:28 -04:00
Daniel Boles
c2672b4f05 Entry: Show optional style classes in node diagram 2018-04-22 16:11:01 +01:00
Timm Bäder
fda98ba562 entry: Remove some questionable code examples 2018-01-07 16:38:41 +00:00
Matthias Clasen
7d23b33ac5 Don't place dnd cursor in placeholder text
That is just misleading - the entire placeholder text is going
to be replaced by the drop.
2017-12-17 10:54:21 -05:00
Daniel Boles
87673af98c Be more specific in ::insert-emoji Since tag
I had been unsure whether to include the minor version, but
:show-emoji-icon already did, so do the same here to match.
2017-11-23 17:17:47 +00:00
Daniel Boles
2c9072314a Add Since to ::insert-emoji, and some trivialities
Document when these keybinding signals were added.
2017-11-22 22:35:25 +00:00
Matthias Clasen
bd56e0d918 Fix indentation mishap 2017-11-22 22:20:28 +00:00
Matthias Clasen
d3eacaf840 entry: Add a key binding for the emoji chooser
Make Ctrl-. and Ctrl-; bring up the emoji chooser.

https://bugzilla.gnome.org/show_bug.cgi?id=789160
2017-11-22 19:11:31 +00:00
Daniel Boles
660cc709fc Entry: Fix leak of text in ensure_has_tooltip()
Thanks to Mohammed Sadiq for noticing this. I guess I got
Widget.get_tooltip_text() confused with Label.get_label().

https://bugzilla.gnome.org/show_bug.cgi?id=787410
2017-09-07 14:54:14 +01:00
Matthias Clasen
172c6c1949 entry: Consider input hints for Emoji support
Don't show "insert emoji" in the context menu if input
hints indicate that Emoji input is not useful.
2017-09-02 08:48:07 -04:00
Matthias Clasen
f0b4b45b76 emoji chooser: Avoid a crash
The emoji chooser gets disposed already, because it is attached
to the toplevel as a popover. Doing it again when the object data
is cleared is leading to a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=787103
2017-09-01 19:53:11 -04:00
Daniel Boles
38b8b3ce1d Entry: Set tooltip text on icon for emoji chooser
https://bugzilla.gnome.org/show_bug.cgi?id=786885
2017-09-01 18:18:45 -04:00
Daniel Boles
794c0946a5 Entry: Rename int helper to gtk_entry_clear_icon()
It was called gtk_entry_clear(), which was unnecessarily vague.
2017-08-30 21:12:56 +01:00
Daniel Boles
12d96f27d3 Entry: Fix Shift-click → extend/truncate selection
Since the move from button-press to gesture events, Shift-clicking did
not work to start a selection (from none) or truncate an existing one.

This was due to the code being copy-pasted around and some logic being
broken in the process. This makes both of those work as they should, by
shuffling it again so the end result is the same as before. Highlights:

(1) ::button-press if extending due to a single press would call
set_positions(tmp_pos, tmp_pos), which is what made the Shift+click to
create a selection work. That was lost. Add it back to make that work.

(2) ::button-press in the “Truncate current selection” branch would not
execute all the stuff around “extend_to_left”, as that was the else
case. So, set extend_selection = FALSE so we skip over that later on.

(3) BUT! This Truncate case never fired because it was in the else
branch of if (in_selection())! Of course, it must be in the true branch.

(4) The IM context was not reset if the Shift-click occurred within an
existing selection, only if it did not. In ::button-press this was the
first thing done if extending a selection, regardless. Make it so again.

https://bugzilla.gnome.org/show_bug.cgi?id=780750
2017-08-30 18:25:00 +01:00
Daniel Boles
669e8c4de5 Entry: Handle :show-emoji-icon becoming false
Disconnect the now-unwanted signal handler, and hide the icon.

https://bugzilla.gnome.org/show_bug.cgi?id=786940
2017-08-28 20:52:29 +01:00
Daniel Boles
6094caf984 Entry: Drop redundant typecasts
https://bugzilla.gnome.org/show_bug.cgi?id=786940
2017-08-28 20:52:26 +01:00
Daniel Boles
fccf19b905 Entry: Only open emoji picker on 2ndary icon click
We hijack the secondary icon for the emoji picker, but the handler for
::icon-press did not check the pressed icon and opened it for either.

https://bugzilla.gnome.org/show_bug.cgi?id=786938
2017-08-28 20:31:02 +01:00
Matthias Clasen
3b493d2937 Drop a redundant helper
We already had a function that does exactly what
is needed here.
2017-08-13 07:52:04 -04:00
Matthias Clasen
e6fd4837a2 Remove an unused field
Nothing uses bubble_window, so it can go.
2017-08-13 07:52:04 -04:00
Matthias Clasen
d56505f74d entry: Add support for an Emoji chooser
Add an "Insert Emoji" item to the context menu in entries.
We also add a show-emoji-icon property, which when set to
TRUE, will add an icon that can be clicked to bring up
the Emoji chooser.
2017-08-11 15:43:49 -04:00
Timm Bäder
8a17848f02 entry: get_icon_area returns in entry coordinates
Document what the returned coordinates are relative to.
2017-08-03 10:23:27 +01:00
Daniel Boles
df10ec7b9b Entry: Fix unset icon tooltip hiding Entry tooltip
Our ::query-tooltip handler first checks whether the pointer is over any
of the icons, returning their tooltip if so, and if not chains up to
Widget::query-tooltip in order to show the text for the widget overall.

But ensure_has_tooltip(), which exists to update :has-tooltip based on
whether ::query-tooltip is needed, only set :has-tooltip to TRUE if any
icon had a tooltip, without caring whether the widget as a whole does.

That is asymmetrical and meant that if the Entry had a tooltip, but
subsequently all icons had their tooltips unset, :has-tooltip would be
set to FALSE, and hence the tooltip for the widget would become lost.

The fix is to set :has-tooltip to TRUE if the widget has a tooltip of
its own, and we only need to check the icons if that is not the case.

https://bugzilla.gnome.org/show_bug.cgi?id=785672
2017-08-01 18:10:38 +01:00
Daniel Boles
ce792384c5 Entry: Warn about corner case hiding icon tooltips
https://bugzilla.gnome.org/show_bug.cgi?id=785672#c4
2017-08-01 18:10:38 +01:00
Daniel Boles
3680e3d40b Entry: Fix get_icon_at_pos()
This was comparing the input position, which is documented as being
relative to the top-left of the Entry allocation, to icon allocations
that were not adjusted accordingly. This could result in tooltips for
icons not being shown in various conditions, since the ::query-tooltip
handler uses get_icon_at_pos() to check whether to show an icon tooltip.

The fix is to compare to the icon border box, not border allocation, as
CssGadget::get_border_box() adjusts relative to the widget. Better yet:
we can just make CssGadget::border_box_contains_point() compare for us.

Delegating to Entry::get_icon_area(), which manually reimplements
CssGadget::get_border_box(), would also work, but this is simpler.

https://bugzilla.gnome.org/show_bug.cgi?id=780938
2017-07-31 20:05:11 +01:00
Timm Bäder
d9170e1978 entry: make sure priv->current_pos is valid
We can e.g. get the entry dispose()d and a focus_out event after that
(because the toplevel unsets the focus which previously was the entry).
We then later use priv->current_pos in a call to pango API which makes
sure the given index is valid for the given layout. Since we lazily
create a GtkEntryBuffer in get_buffer() and a PangoLayout lazily in
gtk_entry_create_layout, these 2 are always valid but don't match
priv->current_pos in this situation.

Fix this by resetting priv->current-pos in dispose().

https://bugzilla.gnome.org/show_bug.cgi?id=785255
2017-07-31 20:05:04 +01:00
Daniel Boles
393e7aacc6 Entry: Add newlines to ease reading huge switches
These are monstrosities!
2017-02-19 12:38:54 +00:00
Daniel Boles
a3d70b4ab2 Entry—Fix inverted movements by arrow keys in RTL
Using Ctrl + left/right to skip between words, or left/right to cancel a
selection, were causing movement on the screen in the opposite direction
of the glyph on the key. This was surprising and awful UX for RTL users.

This is based on a patch covering the former case by:
Author:    Ori Avtalion <ori@avtalion.name>
Date:      Tue Apr 20 08:06:23 2010 +0000

https://bugzilla.gnome.org/show_bug.cgi?id=136059
2017-02-19 12:38:53 +00:00
Sébastien Wilmet
e75601c058 docs: improve the documentation of GtkEntry:attributes
See the implementation of gtk_entry_create_layout():
pango_attr_list_splice() is used to add the PangoAttrList of the preedit
string. And that is done *after* applying the PangoAttrList of the
"attributes" property.

https://bugzilla.gnome.org/show_bug.cgi?id=776868
2017-01-04 20:01:28 +01:00
Sébastien Wilmet
2f940d91a0 docs: fix a parameter name of GtkEntry::populate-popup
Trivial commit.

The documentation block refers to @widget, not @popup. @widget is a
better name since the type is GtkWidget.
2016-11-26 12:35:14 +01:00
Sébastien Wilmet
ca75748223 docs: fix docs of functions to convert layout_index <-> text_index
Trivial commit.

The documentation was swapped. The documentation for the parameters and
the return values is good.
2016-11-26 12:34:48 +01:00
Matthias Clasen
9a257e1f6a entry: Avoid recursion in gtk_entry_ensure_layout
This was unintentional, and lead to a memory leak.
2016-11-14 15:18:25 -05:00
Matthias Clasen
17c08d062f entry: Fix a corner case of overwrite mode
We currently beep when a character is appended at the end in
overwrite mode. That is obviously not right. Patch based on
a patch by Ian MacDonald.

https://bugzilla.gnome.org/show_bug.cgi?id=772389
2016-10-05 12:23:18 -04:00
Christian Hergert
b684b23c74 entry: handle NULL cursor when updating cursors
If we got a NULL cursor from gdk_cursor_new_from_name(), we need
to handle that when unreffing.
2016-09-27 14:12:43 -07:00
Christian Hergert
7ecd337877 entry: handle NULL cursor when releasing reference
If we happen to have gotten NULL back for a cursor, then we
need to check before unreffing it.
2016-09-27 14:09:02 -07: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
Timm Bäder
a985e62b25 Use gtk_popover_popdown/popup where appropriate
https://bugzilla.gnome.org/show_bug.cgi?id=769706
2016-08-16 11:49:26 -04:00
William Hua
8701e34f74 port to new gtk_menu_popup_at_* () functions
https://bugzilla.gnome.org/show_bug.cgi?id=756579
2016-07-19 09:38:54 -04:00
Timm Bäder
4dbe7c99c2 entry: Fix undershoot position wrt entry icons
Draw them inside of the icons, which is where the text scrolls.
2016-05-31 09:41:08 +02:00
Timm Bäder
301652de1f Remove useless casts from gdk_event_triggers_context_menu calls 2016-05-12 20:39:51 +02:00
Matthias Clasen
b5fb9ae3b7 gtk: Port to new monitor api
Use the GdkDisplay monitor api instead of the GdkScreen one.
2016-04-27 23:18:16 -04:00