hu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>

* gtk/gtkstyle.[ch]: Export insertion cursor drawing functionality
        in a simplified form as gtk_draw_insertion_cursor().
        (#99031, request from Alex Larsson)

        * gtk/gtktextdisplay.c gtk/gtkentry.c gtk/gtklabel.c:
        Adapt to new gtk_draw_insertion_cursor().

        * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_class_init)
        gtk/gtkstyle.c (gtk_style_class_init): Add some missed
        Since: 2.4.

        * gtk/gtkiconfactory.c (icon_size_settings_changed)
          gtk/gtkicontheme.c (do_theme_change)
          gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
        * gtk/gtksettings.c (gtk_settings_notify):
        _gtk_rc_reset_styles => gtk_rc_reset_styles.
This commit is contained in:
Owen Taylor 2004-02-26 20:59:01 +00:00
parent 610ae3cbd5
commit 0459484caa
17 changed files with 96 additions and 103 deletions

View File

@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
gtk/gtkstyle.c (gtk_style_class_init): Add some missed
Since: 2.4.
Thu Feb 26 15:43:19 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkiconfactory.c (icon_size_settings_changed)
gtk/gtkicontheme.c (do_theme_change)
gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004 Dom Lachowicz <cinamod@hotmail.com>
* gtk/gtk.def: Export gtk_rc_reset_styles()
>>>>>>> 1.5027
Thu Feb 26 14:47:22 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Export gtk_rc_reset_styles().

View File

@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
gtk/gtkstyle.c (gtk_style_class_init): Add some missed
Since: 2.4.
Thu Feb 26 15:43:19 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkiconfactory.c (icon_size_settings_changed)
gtk/gtkicontheme.c (do_theme_change)
gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004 Dom Lachowicz <cinamod@hotmail.com>
* gtk/gtk.def: Export gtk_rc_reset_styles()
>>>>>>> 1.5027
Thu Feb 26 14:47:22 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Export gtk_rc_reset_styles().

View File

@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
gtk/gtkstyle.c (gtk_style_class_init): Add some missed
Since: 2.4.
Thu Feb 26 15:43:19 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkiconfactory.c (icon_size_settings_changed)
gtk/gtkicontheme.c (do_theme_change)
gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004 Dom Lachowicz <cinamod@hotmail.com>
* gtk/gtk.def: Export gtk_rc_reset_styles()
>>>>>>> 1.5027
Thu Feb 26 14:47:22 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Export gtk_rc_reset_styles().

View File

@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
gtk/gtkstyle.c (gtk_style_class_init): Add some missed
Since: 2.4.
Thu Feb 26 15:43:19 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkiconfactory.c (icon_size_settings_changed)
gtk/gtkicontheme.c (do_theme_change)
gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004 Dom Lachowicz <cinamod@hotmail.com>
* gtk/gtk.def: Export gtk_rc_reset_styles()
>>>>>>> 1.5027
Thu Feb 26 14:47:22 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Export gtk_rc_reset_styles().

View File

@ -11,8 +11,6 @@ Thu Feb 26 15:43:43 2004 Owen Taylor <otaylor@redhat.com>
gtk/gtkstyle.c (gtk_style_class_init): Add some missed
Since: 2.4.
Thu Feb 26 15:43:19 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkiconfactory.c (icon_size_settings_changed)
gtk/gtkicontheme.c (do_theme_change)
gtk/gtkrc.c (_gtk_rc_context_get_default_font_name)
@ -38,7 +36,6 @@ Thu Feb 26 14:47:22 2004 Dom Lachowicz <cinamod@hotmail.com>
* gtk/gtk.def: Export gtk_rc_reset_styles()
>>>>>>> 1.5027
Thu Feb 26 14:47:22 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkrc.[ch]: Export gtk_rc_reset_styles().

View File

@ -4644,6 +4644,7 @@ gtk_paint_vline
gtk_paint_expander
gtk_paint_layout
gtk_paint_resize_grip
gtk_draw_insertion_cursor
<SUBSECTION>
GtkBorder

View File

@ -2861,7 +2861,6 @@ gtk_entry_draw_cursor (GtkEntry *entry,
GtkTextDirection dir2 = GTK_TEXT_DIR_NONE;
gint x1 = 0;
gint x2 = 0;
GdkGC *gc;
gdk_drawable_get_size (entry->text_area, NULL, &text_area_height);
@ -2896,20 +2895,16 @@ gtk_entry_draw_cursor (GtkEntry *entry,
cursor_location.width = 0;
cursor_location.height = text_area_height - 2 * INNER_BORDER ;
gc = _gtk_get_insertion_cursor_gc (widget, TRUE);
_gtk_draw_insertion_cursor (widget, entry->text_area, gc,
&cursor_location, dir1,
dir2 != GTK_TEXT_DIR_NONE);
g_object_unref (gc);
gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
&cursor_location, TRUE, dir1,
dir2 != GTK_TEXT_DIR_NONE);
if (dir2 != GTK_TEXT_DIR_NONE)
{
cursor_location.x = xoffset + x2;
gc = _gtk_get_insertion_cursor_gc (widget, FALSE);
_gtk_draw_insertion_cursor (widget, entry->text_area, gc,
&cursor_location, dir2,
TRUE);
g_object_unref (gc);
gtk_draw_insertion_cursor (widget, entry->text_area, NULL,
&cursor_location, FALSE, dir2,
TRUE);
}
}
}

View File

@ -997,7 +997,7 @@ icon_size_settings_changed (GtkSettings *settings,
{
icon_size_set_all_from_settings (settings);
_gtk_rc_reset_styles (settings);
gtk_rc_reset_styles (settings);
}
static void

View File

@ -565,7 +565,7 @@ do_theme_change (GtkIconTheme *icon_theme)
if (priv->screen && priv->is_screen_singleton)
{
GtkSettings *settings = gtk_settings_get_for_screen (priv->screen);
_gtk_rc_reset_styles (settings);
gtk_rc_reset_styles (settings);
}
}

View File

@ -1723,7 +1723,6 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
GdkRectangle cursor_location;
GtkTextDirection dir1 = GTK_TEXT_DIR_NONE;
GtkTextDirection dir2 = GTK_TEXT_DIR_NONE;
GdkGC *gc;
keymap_direction =
(gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (widget))) == PANGO_DIRECTION_LTR) ?
@ -1766,11 +1765,9 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor1->height);
gc = _gtk_get_insertion_cursor_gc (widget, TRUE);
_gtk_draw_insertion_cursor (widget, widget->window, gc,
&cursor_location, dir1,
dir2 != GTK_TEXT_DIR_NONE);
g_object_unref (gc);
gtk_draw_insertion_cursor (widget, widget->window, NULL,
&cursor_location, TRUE, dir1,
dir2 != GTK_TEXT_DIR_NONE);
if (dir2 != GTK_TEXT_DIR_NONE)
{
@ -1779,10 +1776,9 @@ gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor2->height);
gc = _gtk_get_insertion_cursor_gc (widget, FALSE);
_gtk_draw_insertion_cursor (widget, widget->window, gc,
&cursor_location, dir2, TRUE);
g_object_unref (gc);
gtk_draw_insertion_cursor (widget, widget->window, NULL,
&cursor_location, FALSE, dir2,
TRUE);
}
}
}

View File

@ -132,6 +132,8 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
* vice-versa, and when a buttton is moved from one group of 2 or
* more buttons to a different one, but not when the composition
* of the group that a button belongs to changes.
*
* Since: 2.4
*/
group_changed_signal = g_signal_new ("group-changed",
G_OBJECT_CLASS_TYPE (object_class),

View File

@ -308,8 +308,10 @@ gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass)
* to changes. This is emitted when a radio menu item switches from
* being alone to being part of a group of 2 or more menu items, or
* vice-versa, and when a buttton is moved from one group of 2 or
* more menu items to a different one, but not when the composition
* more menu items ton a different one, but not when the composition
* of the group that a menu item belongs to changes.
*
* Since: 2.4
*/
group_changed_signal = g_signal_new ("group-changed",
G_OBJECT_CLASS_TYPE (object_class),

View File

@ -1398,7 +1398,7 @@ _gtk_rc_context_get_default_font_name (GtkSettings *settings)
g_free (context->font_name);
context->font_name = g_strdup (new_font_name);
_gtk_rc_reset_styles (settings);
gtk_rc_reset_styles (settings);
}
g_free (new_font_name);

View File

@ -594,9 +594,11 @@ gtk_settings_notify (GObject *object,
case PROP_XFT_DPI:
pango_xft_substitute_changed (GDK_SCREEN_XDISPLAY (settings->screen),
GDK_SCREEN_XNUMBER (settings->screen));
/* See comments with _gtk_rc_reset_styles for why this is a hack
/* This is a hack because with gtk_rc_reset_styles() doesn't get
* widgets with gtk_widget_style_set(), and also causes more
* recomputation than necessary.
*/
_gtk_rc_reset_styles (GTK_SETTINGS (object));
gtk_rc_reset_styles (GTK_SETTINGS (object));
break;
#endif /* GDK_WINDOWING_X11 */
}

View File

@ -654,6 +654,8 @@ gtk_style_class_init (GtkStyleClass *klass)
* colormap and depth. Connecting to this signal is probably seldom
* useful since most of the time applications and widgets only
* deal with styles that have been already realized.
*
* Since: 2.4
*/
realize_signal = g_signal_new ("realize",
G_TYPE_FROM_CLASS (object_class),
@ -670,6 +672,8 @@ gtk_style_class_init (GtkStyleClass *klass)
* and depth are being cleaned up. A connection to this signal can be useful
* if a widget wants to cache objects like a #GdkGC as object data on #GtkStyle.
* This signal provides a convenient place to free such cached objects.
*
* Since: 2.4
*/
unrealize_signal = g_signal_new ("unrealize",
G_TYPE_FROM_CLASS (object_class),
@ -6646,28 +6650,9 @@ make_cursor_gc (GtkWidget *widget,
return gtk_gc_get (widget->style->depth, widget->style->colormap, &gc_values, gc_values_mask);
}
/**
* _gtk_get_insertion_cursor_gc:
* @widget: a #GtkWidget
* @is_primary: if the cursor should be the primary cursor color.
*
* Get a GC suitable for drawing the primary or secondary text
* cursor.
*
* Note: the return value is ref'ed because calls to this function
* on other widgets could result in this the GC being released
* which would be an unexpected side effect. If made public,
* this function should possibly be called create_insertion_cursor_gc().
*
* Return value: an appropriate #GdkGC. Call g_object_unref() on
* the gc when you are done with it; this GC may be shared with
* other users, so you must not modify the GC except for temporarily
* setting the clip before drawing with the GC, and then unsetting the clip
* again afterwards.
**/
GdkGC *
_gtk_get_insertion_cursor_gc (GtkWidget *widget,
gboolean is_primary)
static GdkGC *
get_insertion_cursor_gc (GtkWidget *widget,
gboolean is_primary)
{
CursorInfo *cursor_info;
@ -6709,7 +6694,7 @@ _gtk_get_insertion_cursor_gc (GtkWidget *widget,
"cursor-color",
&widget->style->black);
return g_object_ref (cursor_info->primary_gc);
return cursor_info->primary_gc;
}
else
{
@ -6720,31 +6705,17 @@ _gtk_get_insertion_cursor_gc (GtkWidget *widget,
"secondary-cursor-color",
&gray);
return g_object_ref (cursor_info->secondary_gc);
return cursor_info->secondary_gc;
}
}
/**
* _gtk_draw_insertion_cursor:
* @widget: a #GtkWidget
* @drawable: a #GdkDrawable
* @gc: a #GdkGC
* @location: location where to draw the cursor (@location->width is ignored)
* @direction: whether the cursor is left-to-right or
* right-to-left. Should never be #GTK_TEXT_DIR_NONE
* @draw_arrow: %TRUE to draw a directional arrow on the
* cursor. Should be %FALSE unless the cursor is split.
*
* Draws a text caret on @drawable at @location. This is not a style function
* but merely a convenience function for drawing the standard cursor shape.
**/
void
_gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
GtkTextDirection direction,
gboolean draw_arrow)
static void
draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
GtkTextDirection direction,
gboolean draw_arrow)
{
gint stem_width;
gint arrow_width;
@ -6801,3 +6772,48 @@ _gtk_draw_insertion_cursor (GtkWidget *widget,
}
}
}
/**
* gtk_draw_insertion_cursor:
* @widget: a #GtkWidget
* @drawable: a #GdkDrawable
* @area: rectangle to which the output is clipped, or %NULL if the
* output should not be clipped
* @location: location where to draw the cursor (@location->width is ignored)
* @is_primary: if the cursor should be the primary cursor color.
* @direction: whether the cursor is left-to-right or
* right-to-left. Should never be #GTK_TEXT_DIR_NONE
* @draw_arrow: %TRUE to draw a directional arrow on the
* cursor. Should be %FALSE unless the cursor is split.
*
* Draws a text caret on @drawable at @location. This is not a style function
* but merely a convenience function for drawing the standard cursor shape.
*
* Since: 2.4
**/
void
gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkRectangle *area,
GdkRectangle *location,
gboolean is_primary,
GtkTextDirection direction,
gboolean draw_arrow)
{
GdkGC *gc;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GDK_IS_DRAWABLE (drawable));
g_return_if_fail (location != NULL);
g_return_if_fail (direction != GTK_TEXT_DIR_NONE);
gc = get_insertion_cursor_gc (widget, is_primary);
if (area)
gdk_gc_set_clip_rectangle (gc, area);
draw_insertion_cursor (widget, drawable, gc,
location, direction, draw_arrow);
if (area)
gdk_gc_set_clip_rectangle (gc, NULL);
}

View File

@ -885,14 +885,13 @@ void gtk_paint_string (GtkStyle *style,
const gchar *string);
#endif /* GTK_DISABLE_DEPRECATED */
GdkGC *_gtk_get_insertion_cursor_gc (GtkWidget *widget,
gboolean is_primary);
void _gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkGC *gc,
GdkRectangle *location,
GtkTextDirection direction,
gboolean draw_arrow);
void gtk_draw_insertion_cursor (GtkWidget *widget,
GdkDrawable *drawable,
GdkRectangle *area,
GdkRectangle *location,
gboolean is_primary,
GtkTextDirection direction,
gboolean draw_arrow);
#ifdef __cplusplus
}

View File

@ -821,7 +821,6 @@ gtk_text_layout_draw (GtkTextLayout *layout,
GtkTextCursorDisplay *cursor = cursor_list->data;
GtkTextDirection dir;
GdkRectangle cursor_location;
GdkGC *gc;
dir = line_display->direction;
if (have_strong && have_weak)
@ -834,14 +833,10 @@ gtk_text_layout_draw (GtkTextLayout *layout,
cursor_location.y = current_y + line_display->top_margin + cursor->y;
cursor_location.width = 0;
cursor_location.height = cursor->height;
gc = _gtk_get_insertion_cursor_gc (widget, cursor->is_strong);
gdk_gc_set_clip_rectangle(gc, &clip);
_gtk_draw_insertion_cursor (widget, drawable, gc, &cursor_location,
dir, have_strong && have_weak);
gdk_gc_set_clip_rectangle (gc, NULL);
g_object_unref (gc);
gtk_draw_insertion_cursor (widget, drawable, &clip, &cursor_location,
cursor->is_strong,
dir, have_strong && have_weak);
cursor_list = cursor_list->next;
}