[gtk+] GtkWidget: Add gtk_widget_override_cursor().



commit 9aca6c8071e5d00d4d43d2528e79d4eabcab2b9c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Dec 2 22:03:57 2010 +0100

    GtkWidget: Add gtk_widget_override_cursor().
    
    This function replaces gtk_widget_modify_cursor().

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkwidget.c                      |   50 +++++++++++++++++++++++++++++-----
 gtk/gtkwidget.h                      |    4 +++
 3 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 8ab7fd7..632b0bc 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -4850,6 +4850,7 @@ gtk_widget_override_background_color
 gtk_widget_override_color
 gtk_widget_override_font
 gtk_widget_override_symbolic_color
+gtk_widget_override_cursor
 gtk_widget_modify_style
 gtk_widget_get_modifier_style
 gtk_widget_modify_fg
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 1139770..1fefb69 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8094,6 +8094,42 @@ gtk_widget_override_symbolic_color (GtkWidget     *widget,
 }
 
 /**
+ * gtk_widget_override_cursor:
+ * @widget: a #GtkWidget
+ * @primary: the color to use for primary cursor (does not need to be
+ *           allocated), or %NULL to undo the effect of previous calls to
+ *           of gtk_widget_override_cursor().
+ * @secondary: the color to use for secondary cursor (does not need to be
+ *             allocated), or %NULL to undo the effect of previous calls to
+ *             of gtk_widget_override_cursor().
+ *
+ * Sets the cursor color to use in a widget, overriding the
+ * #GtkWidget:cursor-color and #GtkWidget:secondary-cursor-color
+ * style properties. All other style values are left untouched.
+ * See also gtk_widget_modify_style().
+ *
+ * Since: 3.0
+ **/
+void
+gtk_widget_override_cursor (GtkWidget       *widget,
+                            const GdkColor  *cursor,
+                            const GdkColor  *secondary_cursor)
+{
+  GtkModifierStyle *style;
+
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  style = _gtk_widget_get_modifier_properties (widget);
+  gtk_modifier_style_set_color_property (style,
+                                         GTK_TYPE_WIDGET,
+                                         "cursor-color", cursor);
+  gtk_modifier_style_set_color_property (style,
+                                         GTK_TYPE_WIDGET,
+                                         "secondary-cursor-color",
+                                         secondary_cursor);
+}
+
+/**
  * gtk_widget_modify_fg:
  * @widget: a #GtkWidget
  * @state: the state for which to set the foreground color
@@ -8333,22 +8369,22 @@ modify_color_property (GtkWidget      *widget,
  * See also gtk_widget_modify_style().
  *
  * Since: 2.12
+ *
+ * Deprecated: 3.0. Use gtk_widget_override_cursor() instead.
  **/
 void
 gtk_widget_modify_cursor (GtkWidget      *widget,
 			  const GdkColor *primary,
 			  const GdkColor *secondary)
 {
-  GtkRcStyle *rc_style;
-
   g_return_if_fail (GTK_IS_WIDGET (widget));
 
-  rc_style = gtk_widget_get_modifier_style (widget);
+  gtk_widget_override_cursor (widget, primary, secondary);
 
-  modify_color_property (widget, rc_style, "cursor-color", primary);
-  modify_color_property (widget, rc_style, "secondary-cursor-color", secondary);
-
-  gtk_widget_modify_style (widget, rc_style);
+  g_signal_emit (widget,
+                 widget_signals[STYLE_SET],
+                 0,
+                 widget->priv->style);
 }
 
 /**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index afc03e9..83cdb66 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -773,6 +773,10 @@ void         gtk_widget_override_font             (GtkWidget                  *w
 void         gtk_widget_override_symbolic_color   (GtkWidget     *widget,
                                                    const gchar   *name,
                                                    const GdkRGBA *color);
+void         gtk_widget_override_cursor           (GtkWidget       *widget,
+                                                   const GdkColor  *cursor,
+                                                   const GdkColor  *secondary_cursor);
+
 
 void        gtk_widget_style_attach               (GtkWidget     *widget);
 



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