summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@src.gnome.org>2004-02-26 20:59:01 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-02-26 20:59:01 +0000
commit0459484caa2efbabd2fc3fd539c80e3aa42c6b60 (patch)
treecea2981e200b98ea1ef36e70551447b7d497f234 /gtk
parent610ae3cbd5f2957c3080affdeab17f1d5c12a011 (diff)
downloadgtk+-0459484caa2efbabd2fc3fd539c80e3aa42c6b60.tar.gz
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.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkentry.c17
-rw-r--r--gtk/gtkiconfactory.c2
-rw-r--r--gtk/gtkicontheme.c2
-rw-r--r--gtk/gtklabel.c16
-rw-r--r--gtk/gtkradiobutton.c2
-rw-r--r--gtk/gtkradiomenuitem.c4
-rw-r--r--gtk/gtkrc.c2
-rw-r--r--gtk/gtksettings.c6
-rw-r--r--gtk/gtkstyle.c106
-rw-r--r--gtk/gtkstyle.h15
-rw-r--r--gtk/gtktextdisplay.c11
11 files changed, 95 insertions, 88 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 394ca2a6a3..1ea81b3371 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -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);
}
}
}
diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c
index ce5a3c0a24..b7b5521fa2 100644
--- a/gtk/gtkiconfactory.c
+++ b/gtk/gtkiconfactory.c
@@ -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
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 994176f397..f6bc2132b3 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -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);
}
}
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 67399bfc94..deb534d32a 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -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);
}
}
}
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index bbb5e6c212..8ce713fcba 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -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),
diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c
index 771f0aca75..3913f42d37 100644
--- a/gtk/gtkradiomenuitem.c
+++ b/gtk/gtkradiomenuitem.c
@@ -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),
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index f7794a7fa7..7626cb4587 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -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);
diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
index a0421a412e..fab7e95bed 100644
--- a/gtk/gtksettings.c
+++ b/gtk/gtksettings.c
@@ -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 */
}
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index e66e32f6db..212e8f7426 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -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);
+}
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index cc6ac74aa7..80e9a12196 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -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
}
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 55e64099fb..f5937298be 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -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;
}