[gtk+] text handle: Port to CSS nodes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] text handle: Port to CSS nodes
- Date: Tue, 10 Nov 2015 04:50:01 +0000 (UTC)
commit ea51db1feb0aa2ae4a7be31d1d1e328a43a31935
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Nov 9 23:33:54 2015 -0500
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.
gtk/gtktexthandle.c | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
---
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index 14ff454..5ed6ebc 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]