[gtk+/touch-selection-fixes: 3/3] texthandles: Add an extra style	class to the cursor-mode handle
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gtk+/touch-selection-fixes: 3/3] texthandles: Add an extra style	class to the cursor-mode handle
- Date: Fri, 26 Oct 2012 16:01:17 +0000 (UTC)
commit 25d94a2f4b6a7ebde95c8c9551d8d75fbcd61efd
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   |   14 ++++++++++++--
 2 files changed, 21 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 6202f47..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);
@@ -574,6 +580,10 @@ _gtk_text_handle_set_mode (GtkTextHandle     *handle,
     }
 
   priv->mode = mode;
+
+  _gtk_text_handle_update_shape (handle,
+                                 priv->windows[GTK_TEXT_HANDLE_POSITION_CURSOR].window,
+                                 GTK_TEXT_HANDLE_POSITION_CURSOR);
 }
 
 GtkTextHandleMode
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]