]> Pileus Git - ~andy/gtk/commitdiff
GtkWidget: Add gtk_widget_override_cursor().
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 2 Dec 2010 21:03:57 +0000 (22:03 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:39:54 +0000 (15:39 +0100)
This function replaces gtk_widget_modify_cursor().

docs/reference/gtk/gtk3-sections.txt
gtk/gtkwidget.c
gtk/gtkwidget.h

index 8ab7fd76bf1779d3ab1543aa0ec91ec5ba92b379..632b0bc1079d73c7348783d4cc65f247402841fe 100644 (file)
@@ -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
index 11397700489d0eb9772d2ce2e1d85b4ebea01a5d..1fefb69a736c5aacbd56e8f9058c64bb8cb340c3 100644 (file)
@@ -8093,6 +8093,42 @@ gtk_widget_override_symbolic_color (GtkWidget     *widget,
   gtk_modifier_style_map_color (style, name, color);
 }
 
+/**
+ * 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
@@ -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);
 }
 
 /**
index afc03e9d84f00fd80b82db164517334026f367e2..83cdb66270b1bd6dabd745093ebcac0b0fedf8ca 100644 (file)
@@ -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);