Commit Graph

668 Commits

Author SHA1 Message Date
Timm Bäder
25b67af340 textview: Ensure the borders fit into the allocation
https://bugzilla.gnome.org/show_bug.cgi?id=763216
2016-03-09 16:46:00 +01:00
Matthias Clasen
5c0b589acd text view: Respect gtk-keynav-use-caret
When the gtk-keynav-use-caret setting is TRUE, make the cursor
visible regardless of the cursor-visible property.
2016-03-04 22:44:29 -05:00
Matthias Clasen
bbd94b5a9f gtk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Benjamin Otte
6b4788c3ea textview: Support borders in text node 2016-02-27 03:39:51 +01:00
Benjamin Otte
d7bc0fd24c textview: Fix coordinates when background drawing of text node
Fixes black areas in source view of gtk-demo.
2016-02-27 03:27:39 +01:00
Benjamin Otte
4e8fb33f56 pixelcache: Don't have a style context argument
That would imply the pixelcache monitors the style context for changes
and it doesn't do that.

Its only use case was opacity checks, so add
gtk_pixel_cache_se_is_opaque() instead.
2016-02-25 16:52:58 +01:00
Benjamin Otte
8ed804f1b4 textview: Draw the background properly
The background is *not* drawn relative to the clipping area.
2016-02-25 04:03:41 +01: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
6a1722f689 text view: Don't leak cairo transforms
The text view draw function was leaving its cairo context
with a transformation after drawing to all the border windows,
which lead mis-drawing in gitg. Avoid this by moving the
gtk_cairo_transform_to_window call inside the existing
cairo_save/restore calls.

https://bugzilla.gnome.org/show_bug.cgi?id=760942
2016-01-21 23:39:16 -05:00
Matthias Clasen
1821c2df60 text view: Expose cursor blink control
Derived classes like GtkSourceView with their own ::key-event
handler need access to this, in order to make their keynav
as nice as the builtin one, wrt to caret visibility.

https://bugzilla.gnome.org/show_bug.cgi?id=760748
2016-01-18 16:27:43 -05:00
Matthias Clasen
ff5d14f1a8 text view: Update selection node visibility
Make the node invisible if we don't have a selection.
2016-01-18 11:05:53 -05:00
Matthias Clasen
07eda5920f text view: Expand CSS node docs
Mention the selection node, and the context menu.
2016-01-18 10:51:54 -05:00
Alberto Ruiz
496f0892fc introspection: This patch fixes nullable return values fixes for the following symbols in gtk
gtk_accel_group_query
  gtk_accel_group_from_accel_closure
  gtk_accel_label_get_accel_widget
  gtk_accessible_get_widget
  gtk_actionable_get_action_name
  gtk_app_chooser_get_app_info
  gtk_app_chooser_button_get_heading
  gtk_app_chooser_dialog_get_heading
  gtk_application_get_window_by_id
  gtk_assistant_get_nth_page
  gtk_binding_set_find
  gtk_builder_get_object
  gtk_builder_lookup_callback_symbol
  gtk_builder_get_application
  gtk_button_get_image
  gtk_cell_area_get_focus_from_sibling
  gtk_cell_renderer_start_editing
  gtk_cell_view_get_model
  gtk_cell_view_get_displayed_row
  gtk_clipboard_get_owner
  gtk_container_get_focus_child
  gtk_container_get_focus_vadjustment
  gtk_container_get_focus_hadjustment
  gtk_dialog_get_widget_for_response
  gtk_drag_get_source_widget
  gtk_drag_dest_get_target_list
  gtk_drag_source_get_target_list
  gtk_entry_completion_get_model
  gtk_entry_completion_compute_prefix
  gtk_expander_get_label_widget
  gtk_file_chooser_get_filename
  gtk_file_chooser_get_current_folder
  gtk_file_chooser_get_uri
  gtk_file_chooser_get_current_folder_uri
  gtk_file_chooser_get_preview_widget
  gtk_file_chooser_get_preview_file
  gtk_file_chooser_get_preview_filename
  gtk_file_chooser_get_preview_uri
  gtk_file_chooser_get_extra_widget
  gtk_file_chooser_get_filter
  gtk_file_chooser_native_get_accept_label
  gtk_file_chooser_native_get_cancel_label
  gtk_file_filter_get_name
  gtk_font_chooser_get_font_family
  gtk_font_chooser_get_font_face
  gtk_font_chooser_get_font
  gtk_font_chooser_get_font_desc
  gtk_font_chooser_get_font_map
  gtk_frame_get_label
  gtk_gesture_get_device
  gtk_gesture_get_window
  gtk_gl_area_get_error
  gtk_header_bar_get_title
  gtk_header_bar_get_subtitle
  gtk_header_bar_get_custom_title
  gtk_icon_info_get_filename
  gtk_icon_view_get_path_at_pos
  gtk_icon_view_get_model
  gtk_image_get_pixbuf
  gtk_image_get_animation
  gtk_label_get_mnemonic_widget
  gtk_label_get_attributes
  gtk_check_version
  gtk_menu_button_get_popup
  gtk_menu_button_get_menu_model
  gtk_menu_button_get_align_widget
  gtk_menu_button_get_popover
  gtk_menu_item_get_submenu
  gtk_menu_item_get_accel_path
  gtk_native_dialog_get_title
  gtk_native_dialog_get_transient_for
  gtk_notebook_get_nth_page
  gtk_notebook_get_tab_label_text
  gtk_notebook_get_menu_label
  gtk_notebook_get_menu_label_text
  gtk_notebook_get_group_name
  gtk_notebook_get_action_widget
  gtk_offscreen_window_get_surface
  gtk_offscreen_window_get_pixbuf
  gtk_paned_get_child1
  gtk_paned_get_child2
  gtk_places_sidebar_get_location
  gtk_places_sidebar_get_nth_bookmark
  gtk_plug_get_socket_window
  gtk_popover_get_default_widget
  gtk_progress_bar_get_text
  gtk_recent_filter_get_name
  gtk_recent_manager_lookup_item
  gtk_settings_get_default
  gtk_socket_get_plug_window
  gtk_stack_sidebar_get_stack
  gtk_stack_switcher_get_stack
  gtk_style_context_get_section
  gtk_style_context_get_parent
  gtk_style_context_get_frame_clock
  gtk_test_find_widget
  gtk_text_buffer_get_mark
  gtk_text_tag_table_lookup
  gtk_text_view_get_tabs
  gtk_text_view_toggle_cursor_visible
  gtk_text_view_get_window
  gtk_toolbar_get_nth_item
  gtk_tool_button_get_label
  gtk_tool_button_get_icon_name
  gtk_tool_button_get_label_widget
  gtk_tool_button_get_icon_widget
  gtk_tool_palette_get_drop_item
  gtk_tool_palette_get_drop_group
  gtk_tree_model_filter_convert_child_path_to_path
  gtk_tree_model_filter_convert_path_to_child_path
  gtk_tree_model_sort_convert_child_path_to_path
  gtk_tree_model_sort_convert_path_to_child_path
  gtk_tree_view_get_column
  gtk_tree_view_get_bin_window
  gtk_tree_view_column_get_widget
  gtk_tree_view_column_get_tree_view
  gtk_widget_get_frame_clock
  gtk_window_group_get_current_device_grab
  GtkTextBufferSerializeFunc
2016-01-08 12:18:23 +00:00
Benjamin Otte
5cbbc62026 widget: Pass a GtkCssStyleChange instead of a bitmask 2015-12-13 04:11:58 +01:00
Benjamin Otte
971a277419 cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque
object that will compute the changes you are interested in for you.

This simplifies change signal handlers quite a bit and avoids lots of
repeated computation in every signal handler.
2015-12-12 02:16:04 +01:00
Timm Bäder
2182fe7d9d Don't pass widget state flags to GtkStyleContext API 2015-11-22 17:11:35 +01:00
Phillip Wood
ce8b5b4586 Fix character entities
These are not supposed to be supported by gtk-doc¹

¹https://bugzilla.gnome.org/show_bug.cgi?id=758137

https://bugzilla.gnome.org/show_bug.cgi?id=758175
2015-11-19 14:54:57 -05:00
Matthias Clasen
828a66b4aa Cosmetic: Avoid explicit state variables
Using the state of the context makes this more obviously correct.
2015-11-14 12:32:57 -05:00
Matthias Clasen
9d9088304c text view: Improve text rendering
Use the text CSS node for rendering text, and the selection node
for rendering selected text, avoid gtk_style_context_save, update
states of all CSS nodes, and use the proper states when querying
style properties.
2015-11-10 21:49:42 -05:00
Matthias Clasen
bb786ac240 textview: Use a CSS node for selection rendering
Use a CSS node with name selection, like we do for entries
and labels. Unlike those widgets, we currently don't user
gtk_render_background, but just use the background color.
That will require more effort.
2015-11-10 21:18:10 -05:00
Alexander Larsson
0af457639d TextView: Use saner coordinate space in draw_layer.
When I added the draw_layer vfunc it accidentally got passed a cairo_t
that was configured with to draw in the viewport coordinate space (rather
than the buffer coordinate space). This makes things unnecessary complex,
because you have to convert between the two.

The pixel cache is shared between the text and the layers, so there is
no way to use draw_layer to get a stationary overlay effect. Thus it makes
much more sense for the draw_layer vfunc to draw in the buffer space.

Just changing this would break ABI for existing code, so this is fixed
by adding new layer types and deprecating the old ones.

Also, we use the new layer types to fix gtk3-widget-factory.

https://bugzilla.gnome.org/show_bug.cgi?id=757856
2015-11-10 08:39:47 +01:00
Matthias Clasen
a7076d1c4c text view: Add diagram to CSS documentation 2015-11-03 14:27:35 -05:00
Florian Müllner
e364ae3ea8 Use gtk_widget_set_focus_on_click() instead of deprecated setters
https://bugzilla.gnome.org/show_bug.cgi?id=757269
2015-11-03 07:44:17 -05:00
Matthias Clasen
d5ff9af94e entry, textview: Use a dedicated style class for magnifier
This will free up "osd" as an application-level style class,
and lets us style magnifiers differently.
2015-11-02 12:40:38 -05:00
Matthias Clasen
e3ef2c48d5 text view: Add css node docs 2015-10-30 21:00:01 -04:00
Matthias Clasen
844f60f1f2 text view: Convert to CSS nodes
Use subnodes for the border windows, and add children to the right
subnodes.
2015-10-30 19:49:02 -04:00
Matthias Clasen
2b998aaad7 text view: Set an element name
And it will be...drumroll...textview.
2015-10-30 18:11:13 -04:00
Matthias Clasen
95c7a539bf Don't use g_slist_next in gtktextview.c
We generally use ->next directly.
2015-10-20 06:14:57 -04:00
Carlos Garnacho
ab001d01c8 textview: Ensure magnifier popover points within widget area
Otherwise the popopver will be automatically unmapped in
_gtk_popover_update_child_visible() when the X axis (coming more
or less directly from events) goes outside the textview.
2015-10-13 02:07:24 +02:00
Carlos Garnacho
f2fd655754 textview: Look up the drop location iter on the right coordinates on DND
We are passing widget coordinates to gtk_text_view_window_to_buffer_coords()
which expects coordinates to be relative to the text window in this case.
This may result in drop coordinates being displaced if the side windows to
the top/left sides are visible and taking space, so the DnD indicator will
point to the wrong position.

This can be seen on gnome-builder and gedit when displaying line numbers.
2015-09-24 20:47:55 +02:00
Matthias Clasen
525339573e text view: Use qdata with preallocated quarks 2015-09-23 07:01:15 -04:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Christian Hergert
a3605bc557 textview: give pixelcache access to style context
This changes textview to share the style context with the pixelcache.
Doing so allows pixel cache to optimize the surface creation and use
a CAIRO_CONTENT_COLOR instead of CAIRO_CONTENT_COLOR_ALPHA when
appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=754658
2015-09-13 13:41:19 -07:00
Matthias Clasen
3526b08e01 Clean up debug features
Introduce a GTK_DEBUG_CHECK() macro and use it to check for
GTK_DEBUG flags everywhere. Also guard all such places by
2015-09-09 06:32:46 -04:00
Matthias Clasen
6457ee59be text view: Drop an unused variable 2015-09-04 02:11:41 -04:00
Matthias Clasen
1dc4eea096 text view: Improve cursor hiding logic
Same as we did for the entry in the previous commit.

Previously, we just hid the cursor if a key event was adding text,
but not when you used backspace, or Ctrl-V. Rearrange things so that
we obscure the cursor whenever the buffer contents change while we
are handling key events.

https://bugzilla.gnome.org/show_bug.cgi?id=754535
2015-09-03 14:00:27 -04:00
Sebastien Lafargue
9ad6ac0b43 GtkTextView: various scroll fixes
The purpose of this patch is to fix regressions in GtkTextView
scroll behaviours due to commit d138156.
( addition of padding and margins to the view )

Adding some padding is done by, for example, in inspector css tab with:

GtkTextView {
  padding: 10px 10px 10px 10px;
}

and adding margins, by changing one of *-margin properties
( * standing for left/right/top/bottom ) or the corresponding
accessor functions.

Understand that none of these bugs are easy to trigger.
What's happened is that a old and wrong version of the code of the code
( lost in the mean time ) was pushed.

These bugs are best seen with wrap mode set to off.

The commit 8baab8f fix a first regression.

This one is about:

- Cursor going out of the view at line ends instead of being visible
  or triggering the horizontal scroll.

- Padding not displayed correctly
  when moving cursor at beginning/end of lines

- When horizontal scroll position not at left, cursor can make scroll
  by more than one character (you need left padding to see this )

- Moving the cursor arround, the rendered text can be shitted in x or y.
  ( fixed by converting adjustment float values
  to integer before calculations )

  It can be observed by going down with the cursor more
  than the view height then going up

- retval return value of _gtk_text_view_scroll_to_iter wrong in some cases

In addition, this patch re-factor priv->top_border
in screen_dest.y calculation

Of course, all GtkTextView and GtkSourceView based app were impacted
by these bugs ( gedit for example, see bug 754147 )

https://bugzilla.gnome.org/show_bug.cgi?id=753815

https://bugzilla.gnome.org/show_bug.cgi?id=75815
2015-09-01 22:42:23 -04:00
Matthias Clasen
e50c37c8a3 Revert "GtkTextView: various scroll fixes"
This reverts commit 016f6596e7.

Pushed prematurely by accident.
2015-09-01 01:04:53 -04:00
Sebastien Lafargue
016f6596e7 GtkTextView: various scroll fixes
Due to the introduction of view's margin and padding,
some bugs in scrolling behaviour have come.
This commit fix them.

https://bugzilla.gnome.org/show_bug.cgi?id=753815
2015-08-31 23:59:34 -04:00
Christian Hergert
04f3b52c38 textview: handle NULL cursors gracefully
Under some cases, we can get NULL back for the cursor. Simply use
g_clear_object() to handle that case gracefully.
2015-08-31 05:18:29 -07:00
Sebastien Lafargue
8baab8f33d GtkTextView: fix margin/padding scroll behaviour
When you move line by line, only padding is
automaticly shown and you need to use Page key to show margin.

This commit also fix cursor going out of the screen bug.
2015-08-19 22:51:39 +02: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
72d0b4d2c2 text view: Use gtk_simulate_touchscreen
Instead of repeated manual tests.
2015-07-31 13:46:34 -04:00
Matthias Clasen
5c2759af3c Use standard cursor names
This changes GTK+ to use gdk_cursor_new_from_name() with the
'standard' css names, instead of GdkCursorType.

https://bugzilla.gnome.org/show_bug.cgi?id=652085
2015-07-26 01:45:06 -04:00
Cosimo Cecchi
e6f97f10dd textview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Cosimo Cecchi
15908cfdf9 treeview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Carlos Garnacho
5c38991367 textview: Set handles' mode to "none" if showing the bubble
show_or_hide_handles() tries to disable visibility when the popover is
shown, although it triggers a bit late, and lets the handles flash briefly
if both popover and handles try to show at the same time (eg. when
pressing on the selection of a previously unfocused textview, the handles
were previously hidden, so they try to show again on focus in).
2015-06-12 13:04:45 +02:00
Carlos Garnacho
c11906fcdb textview: Perform tougher handle visibility checks after hiding the popover
The handles might fall outside the visible area, and shouldn't be shown
then. Just call gtk_text_view_update_handles() which will perform these
checks, and keep the handle conveniently hidden.

This was leading to unexpectedly visible handles (and in the
wrong/previous position, the handle code doesn't relocate the widget
it's about to hide) when "select all" was selected in the popover on
a textview needing scrollbars.
and extending the selection beyond the view above and/or below.
2015-06-12 12:45:03 +02:00
Carlos Garnacho
8d56346f9b textview: set text direction information on text handles
This makes them point to the correct place, given the theme supports
this.
2015-06-11 17:14:23 +02:00
Matthias Clasen
ac5fcc6b72 text view: Select word on double tap
This is an initial attempt at implementing double-tap selection.
2015-06-09 23:31:00 -04:00