diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-02-14 21:49:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-02-14 21:49:02 +0000 |
commit | 8f5c2c76253447124abc6cf33b69ad53492f6184 (patch) | |
tree | ebf719a9dc960ad37d81f4e94f1dfebcd5e9a2a3 | |
parent | f412d947c5162435f899dc9e5751a67a924e2fe6 (diff) | |
download | gtk+-8f5c2c76253447124abc6cf33b69ad53492f6184.tar.gz |
Patch from Bill Haneman and Padraig O'Briain to add cursor_aspect_ratio
Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c
gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill
Haneman and Padraig O'Briain to add cursor_aspect_ratio
style property to GtkWidget to allow theming the aspect
ratio of the cursor.
* gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c
gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property
to GtkWidget.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 12 | ||||
-rw-r--r-- | gtk/gtkentry.c | 13 | ||||
-rw-r--r-- | gtk/gtklabel.c | 13 | ||||
-rw-r--r-- | gtk/gtkstyle.c | 14 | ||||
-rw-r--r-- | gtk/gtkstyle.h | 3 | ||||
-rw-r--r-- | gtk/gtktextdisplay.c | 2 | ||||
-rw-r--r-- | gtk/gtktextview.c | 16 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 13 | ||||
-rw-r--r-- | tests/testgtkrc | 3 |
15 files changed, 119 insertions, 42 deletions
@@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b496f4b59d..c99f3d0949 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Thu Feb 14 16:46:48 2002 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkentry.c gtk/gtktextdisplay.c gtk/gtklabel.c + gtk/gtkstyle.[ch] gtk/gtkwidget.c: Patch from Bill + Haneman and Padraig O'Briain to add cursor_aspect_ratio + style property to GtkWidget to allow theming the aspect + ratio of the cursor. + + * gtk/gtkentry.c gtk/gtktextview.c gtk/gtklabel.c + gtk/gtkwidget.c tests/testgtkrc: Move cursor-color style property + to GtkWidget. + Thu Feb 14 11:13:22 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkimmulticontext.c (gtk_im_multicontext_get_surrounding): diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index c836371776..7c5bf59992 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -524,13 +524,6 @@ gtk_entry_class_init (GtkEntryClass *class) "", G_PARAM_READABLE | G_PARAM_WRITABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("cursor_color", - _("Cursor color"), - _("Color with which to draw insertion cursor"), - GDK_TYPE_COLOR, - G_PARAM_READABLE)); - signals[POPULATE_POPUP] = gtk_signal_new ("populate_popup", GTK_RUN_LAST, @@ -937,7 +930,7 @@ gtk_entry_realize_cursor_gc (GtkEntry *entry) if (entry->cursor_gc) gdk_gc_unref (entry->cursor_gc); - gtk_widget_style_get (GTK_WIDGET (entry), "cursor_color", &cursor_color, NULL); + gtk_widget_style_get (GTK_WIDGET (entry), "cursor-color", &cursor_color, NULL); entry->cursor_gc = gdk_gc_new (entry->text_area); if (cursor_color) gdk_gc_set_rgb_fg_color (entry->cursor_gc, cursor_color); @@ -2739,13 +2732,13 @@ gtk_entry_draw_cursor (GtkEntry *entry, cursor_location.width = 0; cursor_location.height = text_area_height - 2 * INNER_BORDER ; - _gtk_draw_insertion_cursor (entry->text_area, gc1, + _gtk_draw_insertion_cursor (widget, entry->text_area, gc1, &cursor_location, dir1); if (gc2) { cursor_location.x = xoffset + x2; - _gtk_draw_insertion_cursor (entry->text_area, gc2, + _gtk_draw_insertion_cursor (widget, entry->text_area, gc2, &cursor_location, dir2); } } diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index e038ba4119..b587f953cd 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -373,13 +373,6 @@ gtk_label_class_init (GtkLabelClass *class) 0, G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("cursor_color", - _("Cursor color"), - _("Color with which to draw insertion cursor"), - GDK_TYPE_COLOR, - G_PARAM_READABLE)); - /* * Key bindings */ @@ -1685,7 +1678,7 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset) cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor1->height); - _gtk_draw_insertion_cursor (widget->window, gc1, + _gtk_draw_insertion_cursor (widget, widget->window, gc1, &cursor_location, dir1); if (gc2) @@ -1695,7 +1688,7 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset) cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor2->height); - _gtk_draw_insertion_cursor (widget->window, gc2, + _gtk_draw_insertion_cursor (widget, widget->window, gc2, &cursor_location, dir2); } } @@ -1938,7 +1931,7 @@ gtk_label_realize_cursor_gc (GtkLabel *label) if (label->select_info->cursor_gc) gdk_gc_unref (label->select_info->cursor_gc); - gtk_widget_style_get (GTK_WIDGET (label), "cursor_color", &cursor_color, NULL); + gtk_widget_style_get (GTK_WIDGET (label), "cursor-color", &cursor_color, NULL); label->select_info->cursor_gc = gdk_gc_new (GTK_WIDGET (label)->window); if (cursor_color) gdk_gc_set_rgb_fg_color (label->select_info->cursor_gc, cursor_color); diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index fa21026ac6..fa81482e65 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -5474,6 +5474,7 @@ gtk_style_set_font (GtkStyle *style, /** * _gtk_draw_insertion_cursor: + * @widget: a #GtkWidget * @drawable: a #GdkDrawable * @gc: a #GdkGC * @location: location where to draw the cursor (@location->width is ignored) @@ -5485,16 +5486,23 @@ gtk_style_set_font (GtkStyle *style, * but merely a convenience function for drawing the standard cursor shape. **/ void -_gtk_draw_insertion_cursor (GdkDrawable *drawable, +_gtk_draw_insertion_cursor (GtkWidget *widget, + GdkDrawable *drawable, GdkGC *gc, GdkRectangle *location, GtkTextDirection dir) { - gint stem_width = location->height / 30 + 1; - gint arrow_width = stem_width + 1; + gint stem_width; + gint arrow_width; gint x, y; gint i; + gfloat cursor_aspect_ratio; + gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL); + + stem_width = location->height * cursor_aspect_ratio + 1; + arrow_width = stem_width + 1; + for (i = 0; i < stem_width; i++) gdk_draw_line (drawable, gc, location->x + i - stem_width / 2, location->y, diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 5ac6eb1261..9e15db5785 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -866,7 +866,8 @@ void gtk_paint_string (GtkStyle *style, const gchar *string); #endif /* GTK_DISABLE_DEPRECATED */ -void _gtk_draw_insertion_cursor (GdkDrawable *drawable, +void _gtk_draw_insertion_cursor (GtkWidget *widget, + GdkDrawable *drawable, GdkGC *gc, GdkRectangle *location, GtkTextDirection dir); diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c index fd5a9d137e..b3acdab830 100644 --- a/gtk/gtktextdisplay.c +++ b/gtk/gtktextdisplay.c @@ -859,7 +859,7 @@ gtk_text_layout_draw (GtkTextLayout *layout, cursor_location.height = cursor->height; gdk_gc_set_clip_rectangle(gc, &clip); - _gtk_draw_insertion_cursor (drawable, gc, &cursor_location, dir); + _gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location, dir); gdk_gc_set_clip_rectangle (gc, NULL); cursor_list = cursor_list->next; diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 1ed23146a4..f158456016 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -326,7 +326,7 @@ static void gtk_text_view_remove (GtkContainer *container, GtkWidget *child); static void gtk_text_view_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, + GtkCallback callback, gpointer callback_data); /* FIXME probably need the focus methods. */ @@ -634,18 +634,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass) /* - * Style properties - */ - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("cursor_color", - _("Cursor color"), - _("Color with which to draw insertion cursor"), - GDK_TYPE_COLOR, - G_PARAM_READABLE)); - - - /* * Signals */ @@ -3270,7 +3258,7 @@ gtk_text_view_realize_cursor_gc (GtkTextView *text_view) if (text_view->cursor_gc) gdk_gc_unref (text_view->cursor_gc); - gtk_widget_style_get (GTK_WIDGET (text_view), "cursor_color", &cursor_color, NULL); + gtk_widget_style_get (GTK_WIDGET (text_view), "cursor-color", &cursor_color, NULL); if (!cursor_color) cursor_color = &red; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 04fe3f31a1..487c80f508 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -1074,7 +1074,18 @@ gtk_widget_class_init (GtkWidgetClass *klass) _("Width, in pixels, between focus indicator and the widget 'box'."), 0, G_MAXINT, 1, G_PARAM_READWRITE)); - + gtk_widget_class_install_style_property (klass, + g_param_spec_boxed ("cursor-color", + _("Cursor color"), + _("Color with which to draw insertion cursor"), + GDK_TYPE_COLOR, + G_PARAM_READABLE)); + gtk_widget_class_install_style_property (klass, + g_param_spec_float ("cursor-aspect-ratio", + _("Cursor line aspect ratio"), + _("Aspect ratio with which to draw insertion cursor"), + 0.0, 1.0, 0.033, + G_PARAM_READABLE)); } static void diff --git a/tests/testgtkrc b/tests/testgtkrc index 4ef1acbaec..307c0689c6 100644 --- a/tests/testgtkrc +++ b/tests/testgtkrc @@ -34,8 +34,7 @@ style "global-style-properties" # xthickness = 20 GtkButton::child_displacement_x = 1 GtkButton::child_displacement_y = 1 - GtkSpinButton::shadow_type = etched-out - GtkEntry::cursor_color = "#ff0000" + GtkWidget::cursor_color = "#ff0000" GtkToolbar::space_size = 10 GtkToolbar::space_style = line GtkToolbar::button_relief = none |