summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-11-09 23:33:54 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-11-09 23:33:54 -0500
commitea51db1feb0aa2ae4a7be31d1d1e328a43a31935 (patch)
treed2b6315993531afd078d9247b1cd3678c9e95a49
parent14f4b7ead21f57a10ddf56a45966b78b3dbbe6c1 (diff)
downloadgtk+-ea51db1feb0aa2ae4a7be31d1d1e328a43a31935.tar.gz
text handle: Port to CSS nodes
Use cursor-handle as the element name for the CSS node that is used to render text the selection handles.
-rw-r--r--gtk/gtktexthandle.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index 14ff4542d1..5ed6ebce31 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -21,6 +21,8 @@
#include "gtkmarshalers.h"
#include "gtkprivate.h"
#include "gtkwindowprivate.h"
+#include "gtkcssnodeprivate.h"
+#include "gtkwidgetprivate.h"
#include "gtkintl.h"
#include <gtk/gtk.h>
@@ -111,29 +113,10 @@ _gtk_text_handle_draw (GtkTextHandle *handle,
_gtk_text_handle_get_size (handle, &width, &height);
cairo_save (cr);
-
cairo_translate (cr, handle_window->border.left, handle_window->border.top);
- gtk_style_context_save (context);
- gtk_style_context_add_class (context,
- GTK_STYLE_CLASS_CURSOR_HANDLE);
-
- if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
- {
- gtk_style_context_add_class (context,
- GTK_STYLE_CLASS_BOTTOM);
-
- if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR)
- gtk_style_context_add_class (context,
- GTK_STYLE_CLASS_INSERTION_CURSOR);
- }
- else
- gtk_style_context_add_class (context,
- GTK_STYLE_CLASS_TOP);
-
gtk_render_handle (context, cr, 0, 0, width, height);
- gtk_style_context_restore (context);
cairo_restore (cr);
}
@@ -300,6 +283,7 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
if (!priv->windows[pos].widget)
{
GtkWidget *widget, *window;
+ GtkStyleContext *context;
widget = gtk_event_box_new ();
gtk_event_box_set_visible_window (GTK_EVENT_BOX (widget), TRUE);
@@ -324,8 +308,17 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW);
_gtk_window_add_popover (GTK_WINDOW (window), widget, priv->parent, FALSE);
- gtk_style_context_set_parent (gtk_widget_get_style_context (widget),
- gtk_widget_get_style_context (priv->parent));
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_set_parent (context, gtk_widget_get_style_context (priv->parent));
+ gtk_css_node_set_name (gtk_widget_get_css_node (widget), I_("cursor-handle"));
+ if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
+ {
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
+ if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR)
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_INSERTION_CURSOR);
+ }
+ else
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
}
return priv->windows[pos].widget;
@@ -771,6 +764,14 @@ _gtk_text_handle_set_mode (GtkTextHandle *handle,
break;
}
+ if (end->widget)
+ {
+ if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
+ gtk_style_context_add_class (gtk_widget_get_style_context (end->widget), GTK_STYLE_CLASS_INSERTION_CURSOR);
+ else
+ gtk_style_context_remove_class (gtk_widget_get_style_context (end->widget), GTK_STYLE_CLASS_INSERTION_CURSOR);
+ }
+
_gtk_text_handle_update (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START);
_gtk_text_handle_update (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END);