[gtk+/touch-selection-fixes: 3/3] texthandles: Add an extra style class to the cursor-mode handle



commit 0aa0a85e1d9b5bb6d7d59f241dc66e99069b25b5
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Oct 26 17:57:03 2012 +0200

    texthandles: Add an extra style class to the cursor-mode handle
    
    Themes may want to render handles differently depending on whether
    the widget is in selection mode (2 handles enclosing a selection) or
    cursor mode (one handle pointing out the insertion cursor).

 gtk/gtkstylecontext.h |    9 +++++++++
 gtk/gtktexthandle.c   |   10 ++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 1783d4c..82f60f7 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -709,6 +709,15 @@ struct _GtkStyleContextClass
  */
 #define GTK_STYLE_CLASS_CURSOR_HANDLE "cursor-handle"
 
+/**
+ * GTK_STYLE_CLASS_INSERT_CURSOR:
+ *
+ * A CSS class used when rendering a drag handle for
+ * the insertion cursor position.
+ */
+#define GTK_STYLE_CLASS_INSERT_CURSOR "insert-cursor"
+
+
 /* Predefined set of widget regions */
 
 /**
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index 3d06ee4..806d227 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -108,8 +108,14 @@ _gtk_text_handle_draw (GtkTextHandle         *handle,
                                GTK_STYLE_CLASS_CURSOR_HANDLE);
 
   if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
-    gtk_style_context_add_class (priv->style_context,
-                                 GTK_STYLE_CLASS_BOTTOM);
+    {
+      gtk_style_context_add_class (priv->style_context,
+                                   GTK_STYLE_CLASS_BOTTOM);
+
+      if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR)
+        gtk_style_context_add_class (priv->style_context,
+                                     GTK_STYLE_CLASS_INSERT_CURSOR);
+    }
   else
     gtk_style_context_add_class (priv->style_context,
                                  GTK_STYLE_CLASS_TOP);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]