diff options
author | Havoc Pennington <hp@redhat.com> | 2001-05-07 15:58:47 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-05-07 15:58:47 +0000 |
commit | b4e4a0ed9d66132efad0539bc5901b35ea262d88 (patch) | |
tree | 7eea37afc0c2f32334112872547373758ac7d6b6 /gtk | |
parent | 607ac1e1b31dc21598830a22930bcc39a77cb5c3 (diff) | |
download | gtk+-b4e4a0ed9d66132efad0539bc5901b35ea262d88.tar.gz |
fix some shell typos
2001-05-04 Havoc Pennington <hp@redhat.com>
* configure.in: fix some shell typos
* gtk/gtkcolorsel.c (gtk_color_selection_destroy): warning fix
* gtk/gtkimage.c: handle animations
* gtk/gtkcheckbutton.c (gtk_check_button_size_request): request
border_width * 2, not just border_width
* gtk/gtkscale.c: add "format_value" signal to allow people
to override the way values are drawn.
(gtk_scale_get_value_size): fix width/height mistake,
and compute size from actual displayed text, not
from made-up text.
* gtk/gtktexttag.c (gtk_text_tag_class_init): fix return type in
signal registration
* tests/testtext.c: Add "Remove all tags" menu item for testing
* gtk/gtktextbuffer.c (gtk_text_buffer_remove_all_tags): implement
* demos/gtk-demo/main.c (main): add hack so we can find modules
without installing gtk
* demos/gtk-demo/textview.c (insert_text): demo font scaling
* gtk/gtkcellrenderertext.c: Add "scale" property (font scaling
factor)
(gtk_cell_renderer_text_set_property): remove some bogus
g_object_notify
* gtk/gtktexttag.c: add "scale" property which is a font scaling
factor
* gtk/gtktextlayout.c (add_text_attrs): add font scale attribute
to layout
* gtk/gtktextiter.c (gtk_text_iter_is_start): rename from
gtk_text_iter_is_first
2001-05-04 Havoc Pennington <hp@redhat.com>
* pixops/pixops.c (pixops_process): merge fix from stable: Patch
from hoshem@mel.comcen.com.au to fix nonzero X offsets. Fixes
bug #50371.
* gdk-pixbuf/pixops/pixops.c (pixops_composite_nearest): merge
from stable: Patch from OKADA Mitsuru <m-okada@fjb.co.jp> to fix
confusion of using "src" instead of "p".
(pixops_composite_color_nearest): Use a more accurate (and
correct, to begin with) compositing method. This cures checks
showing through on images with no alpha.
* gdk-pixbuf.c (gdk_pixbuf_fill): fix bug that left some trailing
bytes unfilled.
* gdk-pixbuf-io.h: fix UpdatedNotifyFunc to use signed ints
* gdk-pixbuf-loader.h (struct _GdkPixbufLoaderClass): Change
area_updated signal to use signed ints. Removed animation-related
signals.
* io-gif.c, io-gif-animation.h, io-gif-animation.c: Massive
rewrite action
* gdk-pixbuf-animation.c: Add GdkPixbufAnimationIter to abstract
all the pesky details. Remove old frame-based API. Make
GdkPixbufAnimation an abstract base class, derived by the loaders.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkcellrenderertext.c | 50 | ||||
-rw-r--r-- | gtk/gtkcellrenderertext.h | 3 | ||||
-rw-r--r-- | gtk/gtkcheckbutton.c | 6 | ||||
-rw-r--r-- | gtk/gtkcolorsel.c | 2 | ||||
-rw-r--r-- | gtk/gtkhscale.c | 10 | ||||
-rw-r--r-- | gtk/gtkimage.c | 246 | ||||
-rw-r--r-- | gtk/gtkimage.h | 70 | ||||
-rw-r--r-- | gtk/gtkmarshal.list | 1 | ||||
-rw-r--r-- | gtk/gtkmarshalers.list | 1 | ||||
-rw-r--r-- | gtk/gtkrange.h | 3 | ||||
-rw-r--r-- | gtk/gtkscale.c | 113 | ||||
-rw-r--r-- | gtk/gtkscale.h | 6 | ||||
-rw-r--r-- | gtk/gtktextbuffer.c | 121 | ||||
-rw-r--r-- | gtk/gtktextbuffer.h | 3 | ||||
-rw-r--r-- | gtk/gtktextiter.c | 6 | ||||
-rw-r--r-- | gtk/gtktextiter.h | 7 | ||||
-rw-r--r-- | gtk/gtktextlayout.c | 10 | ||||
-rw-r--r-- | gtk/gtktexttag.c | 44 | ||||
-rw-r--r-- | gtk/gtktexttag.h | 3 | ||||
-rw-r--r-- | gtk/gtktextview.c | 1 | ||||
-rw-r--r-- | gtk/gtkvscale.c | 11 |
21 files changed, 592 insertions, 125 deletions
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c index 9a6f65cbfd..706fffd2c3 100644 --- a/gtk/gtkcellrenderertext.c +++ b/gtk/gtkcellrenderertext.c @@ -70,6 +70,7 @@ enum { PROP_STRETCH, PROP_SIZE, PROP_SIZE_POINTS, + PROP_SCALE, PROP_EDITABLE, PROP_STRIKETHROUGH, PROP_UNDERLINE, @@ -84,6 +85,7 @@ enum { PROP_WEIGHT_SET, PROP_STRETCH_SET, PROP_SIZE_SET, + PROP_SCALE_SET, PROP_EDITABLE_SET, PROP_STRIKETHROUGH_SET, PROP_UNDERLINE_SET, @@ -282,6 +284,16 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) G_MAXDOUBLE, 0.0, G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, + PROP_SCALE, + g_param_spec_double ("scale", + _("Font scale"), + _("Font scaling factor"), + 0.0, + G_MAXDOUBLE, + 1.0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, PROP_RISE, @@ -351,6 +363,10 @@ gtk_cell_renderer_text_class_init (GtkCellRendererTextClass *class) _("Font size set"), _("Whether this tag affects the font size")); + ADD_SET_PROP ("scale_set", PROP_SCALE_SET, + _("Font scale set"), + _("Whether this tag scales the font size by a factor")); + ADD_SET_PROP ("rise_set", PROP_RISE_SET, _("Rise set"), _("Whether this tag affects the rise")); @@ -462,6 +478,10 @@ gtk_cell_renderer_text_get_property (GObject *object, g_value_set_double (value, ((double)celltext->font.size) / (double)PANGO_SCALE); break; + case PROP_SCALE: + g_value_set_double (value, celltext->font_scale); + break; + case PROP_EDITABLE: g_value_set_boolean (value, celltext->editable); break; @@ -510,6 +530,10 @@ gtk_cell_renderer_text_get_property (GObject *object, g_value_set_boolean (value, celltext->size_set); break; + case PROP_SCALE_SET: + g_value_set_boolean (value, celltext->scale_set); + break; + case PROP_EDITABLE_SET: g_value_set_boolean (value, celltext->editable_set); break; @@ -824,6 +848,11 @@ gtk_cell_renderer_text_set_property (GObject *object, g_object_notify (G_OBJECT (celltext), "font"); break; + case PROP_SCALE: + celltext->font_scale = g_value_get_double (value); + celltext->scale_set = TRUE; + break; + case PROP_SIZE_POINTS: celltext->font.size = g_value_get_double (value) * PANGO_SCALE; @@ -849,6 +878,7 @@ gtk_cell_renderer_text_set_property (GObject *object, celltext->underline_style = g_value_get_enum (value); celltext->underline_set = TRUE; g_object_notify (G_OBJECT (celltext), "underline_set"); + break; case PROP_RISE: @@ -859,62 +889,54 @@ gtk_cell_renderer_text_set_property (GObject *object, case PROP_BACKGROUND_SET: celltext->background_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "background_set"); break; case PROP_FOREGROUND_SET: celltext->foreground_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "foreground_set"); break; case PROP_FAMILY_SET: celltext->family_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "family_set"); break; case PROP_STYLE_SET: celltext->style_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "style_set"); break; case PROP_VARIANT_SET: celltext->variant_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "variant_set"); break; case PROP_WEIGHT_SET: celltext->weight_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "weight_set"); break; case PROP_STRETCH_SET: celltext->stretch_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "stretch_set"); break; case PROP_SIZE_SET: celltext->size_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "size_set"); break; + case PROP_SCALE_SET: + celltext->scale_set = g_value_get_boolean (value); + break; + case PROP_EDITABLE_SET: celltext->editable_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "editable_set"); break; case PROP_STRIKETHROUGH_SET: celltext->strikethrough_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "strikethrough_set"); break; case PROP_UNDERLINE_SET: celltext->underline_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "underline_set"); break; case PROP_RISE_SET: celltext->rise_set = g_value_get_boolean (value); - g_object_notify(G_OBJECT(object), "rise_set"); break; default: @@ -1012,6 +1034,10 @@ get_layout (GtkCellRendererText *celltext, celltext->font.size >= 0) add_attr (attr_list, pango_attr_size_new (celltext->font.size)); + if (celltext->scale_set && + celltext->font_scale != 1.0) + add_attr (attr_list, pango_attr_scale_new (celltext->font_scale)); + if (celltext->underline_set) uline = celltext->underline_style; else diff --git a/gtk/gtkcellrenderertext.h b/gtk/gtkcellrenderertext.h index fd906a3350..3ec1852288 100644 --- a/gtk/gtkcellrenderertext.h +++ b/gtk/gtkcellrenderertext.h @@ -44,6 +44,7 @@ struct _GtkCellRendererText /*< private >*/ gchar *text; PangoFontDescription font; + gdouble font_scale; PangoColor foreground; PangoColor background; @@ -66,6 +67,8 @@ struct _GtkCellRendererText guint stretch_set : 1; guint size_set : 1; + guint scale_set : 1; + guint foreground_set : 1; guint background_set : 1; diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 802b85e017..f888e65113 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -246,8 +246,8 @@ gtk_check_button_size_request (GtkWidget *widget, gint indicator_spacing; gint border_width = GTK_CONTAINER (widget)->border_width; - requisition->width = border_width + 2; - requisition->height = border_width + 2; + requisition->width = border_width * 2 + 2; + requisition->height = border_width * 2 + 2; child = GTK_BIN (widget)->child; if (child && GTK_WIDGET_VISIBLE (child)) @@ -255,7 +255,7 @@ gtk_check_button_size_request (GtkWidget *widget, GtkRequisition child_requisition; gtk_widget_size_request (child, &child_requisition); - + requisition->width += child_requisition.width; requisition->height += child_requisition.height; } diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index a894e9fc5c..4f1e61ac4f 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -1848,7 +1848,7 @@ gtk_color_selection_destroy (GtkObject *object) if (priv->tooltips) { - gtk_object_destroy (priv->tooltips); + gtk_object_destroy (GTK_OBJECT (priv->tooltips)); priv->tooltips = NULL; } diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 0fa644b68a..29f6321fbf 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -523,7 +523,6 @@ gtk_hscale_draw_value (GtkScale *scale) { GtkStateType state_type; GtkWidget *widget; - gchar buffer[32]; gint width, height; gint x, y; @@ -536,9 +535,14 @@ gtk_hscale_draw_value (GtkScale *scale) { PangoLayout *layout; PangoRectangle logical_rect; + gchar *txt; + + txt = _gtk_scale_format_value (scale, + GTK_RANGE (scale)->adjustment->value); + + layout = gtk_widget_create_pango_layout (widget, txt); + g_free (txt); - sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); - layout = gtk_widget_create_pango_layout (widget, buffer); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); switch (scale->value_pos) diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 81f0debc18..e5890a16c4 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -28,11 +28,13 @@ #include "gtkimage.h" #include "gtkiconfactory.h" #include "gtkstock.h" +#include <string.h> static void gtk_image_class_init (GtkImageClass *klass); static void gtk_image_init (GtkImage *image); static gint gtk_image_expose (GtkWidget *widget, GdkEventExpose *event); +static void gtk_image_unmap (GtkWidget *widget); static void gtk_image_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_image_destroy (GtkObject *object); @@ -85,6 +87,7 @@ gtk_image_class_init (GtkImageClass *class) widget_class->expose_event = gtk_image_expose; widget_class->size_request = gtk_image_size_request; + widget_class->unmap = gtk_image_unmap; } static void @@ -163,11 +166,22 @@ gtk_image_new_from_image (GdkImage *gdk_image, * gtk_image_new_from_file: * @filename: a filename * - * Creates a new #GtkImage displaying the file @filename. If the - * file isn't found or can't be loaded, the #GtkImage will display - * a "broken image" icon. If you need to detect failures to load - * the file, use gdk_pixbuf_new_from_file() to load the file yourself, - * then create the #GtkImage from the pixbuf. + * Creates a new #GtkImage displaying the file @filename. If the file + * isn't found or can't be loaded, the resulting #GtkImage will + * display a "broken image" icon. This function never returns %NULL, + * it always returns a valid #GtkImage widget. + * + * If the file contains an animation, the image will contain an + * animation. + * + * If you need to detect failures to load the file, use + * gdk_pixbuf_new_from_file() to load the file yourself, then create + * the #GtkImage from the pixbuf. (Or for animations, use + * gdk_pixbuf_animation_new_from_file()). + * + * The storage type (gtk_image_get_storage_type()) of the returned + * image is not defined, it will be whatever is appropriate for + * displaying the file. * * Return value: a new #GtkImage **/ @@ -194,7 +208,7 @@ gtk_image_new_from_file (const gchar *filename) * * Note that this function just creates an #GtkImage from the pixbuf. The * #GtkImage created will not react to state changes. Should you want that, you - * should use @gtk_image_new_from_icon_set. + * should use gtk_image_new_from_icon_set(). * * Return value: a new #GtkImage **/ @@ -269,6 +283,31 @@ gtk_image_new_from_icon_set (GtkIconSet *icon_set, } /** + * gtk_image_new_from_animation: + * @animation: an animation + * + * Creates a #GtkImage displaying the given animation. + * The #GtkImage does not assume a reference to the + * animation; you still need to unref it if you own references. + * #GtkImage will add its own reference rather than adopting yours. + * + * Return value: a new #GtkImage widget + **/ +GtkWidget* +gtk_image_new_from_animation (GdkPixbufAnimation *animation) +{ + GtkImage *image; + + g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL); + + image = gtk_type_new (GTK_TYPE_IMAGE); + + gtk_image_set_from_animation (image, animation); + + return GTK_WIDGET (image); +} + +/** * gtk_image_set_from_pixmap: * @image: a #GtkImage * @pixmap: a #GdkPixmap or %NULL @@ -376,7 +415,7 @@ void gtk_image_set_from_file (GtkImage *image, const gchar *filename) { - GdkPixbuf *pixbuf; + GdkPixbufAnimation *anim; g_return_if_fail (GTK_IS_IMAGE (image)); g_return_if_fail (filename != NULL); @@ -386,9 +425,9 @@ gtk_image_set_from_file (GtkImage *image, if (filename == NULL) return; - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + anim = gdk_pixbuf_animation_new_from_file (filename, NULL); - if (pixbuf == NULL) + if (anim == NULL) { gtk_image_set_from_stock (image, GTK_STOCK_MISSING_IMAGE, @@ -396,9 +435,22 @@ gtk_image_set_from_file (GtkImage *image, return; } - gtk_image_set_from_pixbuf (image, pixbuf); + /* We could just unconditionally set_from_animation, + * but it's nicer for memory if we toss the animation + * if it's just a single pixbuf + */ - g_object_unref (G_OBJECT (pixbuf)); + if (gdk_pixbuf_animation_is_static_image (anim)) + { + gtk_image_set_from_pixbuf (image, + gdk_pixbuf_animation_get_static_image (anim)); + } + else + { + gtk_image_set_from_animation (image, anim); + } + + g_object_unref (G_OBJECT (anim)); } /** @@ -501,6 +553,41 @@ gtk_image_set_from_icon_set (GtkImage *image, } /** + * gtk_image_set_from_animation: + * @image: a #GtkImage + * @animation: the #GdkPixbufAnimation + * + * Causes the #GtkImage to display the given animation (or display + * nothing, if you set the animation to %NULL). + **/ +void +gtk_image_set_from_animation (GtkImage *image, + GdkPixbufAnimation *animation) +{ + g_return_if_fail (GTK_IS_IMAGE (image)); + g_return_if_fail (animation == NULL || + GDK_IS_PIXBUF_ANIMATION (animation)); + + if (animation) + g_object_ref (G_OBJECT (animation)); + + gtk_image_reset (image); + + if (animation != NULL) + { + image->storage_type = GTK_IMAGE_ANIMATION; + + image->data.anim.anim = animation; + image->data.anim.frame_timeout = 0; + image->data.anim.iter = NULL; + + gtk_image_update_size (image, + gdk_pixbuf_animation_get_width (animation), + gdk_pixbuf_animation_get_height (animation)); + } +} + +/** * gtk_image_get_storage_type: * @image: a #GtkImage * @@ -660,6 +747,33 @@ gtk_image_get_icon_set (GtkImage *image, *size = image->data.icon_set.size; } +/** + * gtk_image_get_animation: + * @image: a #GtkImage + * + * + * Gets the #GdkPixbufAnimation being displayed by the #GtkImage. + * The storage type of the image must be %GTK_IMAGE_EMPTY or + * %GTK_IMAGE_ANIMATION (see gtk_image_get_storage_type()). + * The caller of this function does not own a reference to the + * returned animation. + * + * Return value: the displayed animation, or %NULL if the image is empty + **/ +GdkPixbufAnimation* +gtk_image_get_animation (GtkImage *image) +{ + g_return_val_if_fail (GTK_IS_IMAGE (image), NULL); + g_return_val_if_fail (image->storage_type == GTK_IMAGE_ANIMATION || + image->storage_type == GTK_IMAGE_EMPTY, + NULL); + + if (image->storage_type == GTK_IMAGE_EMPTY) + image->data.anim.anim = NULL; + + return image->data.anim.anim; +} + GtkWidget* gtk_image_new (GdkImage *val, GdkBitmap *mask) @@ -695,6 +809,55 @@ gtk_image_get (GtkImage *image, gtk_image_get_image (image, val, mask); } +static void +gtk_image_unmap (GtkWidget *widget) +{ + GtkImage *image; + + image = GTK_IMAGE (widget); + + if (image->storage_type == GTK_IMAGE_ANIMATION) + { + /* Reset the animation */ + + if (image->data.anim.frame_timeout) + { + g_source_remove (image->data.anim.frame_timeout); + image->data.anim.frame_timeout = 0; + } + + if (image->data.anim.iter) + { + g_object_unref (G_OBJECT (image->data.anim.iter)); + image->data.anim.iter = NULL; + } + } + + if (GTK_WIDGET_CLASS (parent_class)->unmap) + GTK_WIDGET_CLASS (parent_class)->unmap (widget); +} + +gint +animation_timeout (gpointer data) +{ + GtkImage *image; + + image = GTK_IMAGE (data); + + image->data.anim.frame_timeout = 0; + + gdk_pixbuf_animation_iter_advance (image->data.anim.iter, NULL); + + if (gdk_pixbuf_animation_iter_get_delay_time (image->data.anim.iter) >= 0) + image->data.anim.frame_timeout = + g_timeout_add (gdk_pixbuf_animation_iter_get_delay_time (image->data.anim.iter), + animation_timeout, + image); + + gtk_widget_queue_draw (GTK_WIDGET (image)); + + return FALSE; +} static gint gtk_image_expose (GtkWidget *widget, @@ -777,6 +940,24 @@ gtk_image_expose (GtkWidget *widget, image_bound.height = gdk_pixbuf_get_height (stock_pixbuf); } break; + + case GTK_IMAGE_ANIMATION: + { + if (image->data.anim.iter == NULL) + { + image->data.anim.iter = gdk_pixbuf_animation_get_iter (image->data.anim.anim, NULL); + + if (gdk_pixbuf_animation_iter_get_delay_time (image->data.anim.iter) >= 0) + image->data.anim.frame_timeout = + g_timeout_add (gdk_pixbuf_animation_iter_get_delay_time (image->data.anim.iter), + animation_timeout, + image); + } + + image_bound.width = gdk_pixbuf_animation_get_width (image->data.anim.anim); + image_bound.height = gdk_pixbuf_animation_get_height (image->data.anim.anim); + } + break; default: break; @@ -849,6 +1030,25 @@ gtk_image_expose (GtkWidget *widget, } break; + case GTK_IMAGE_ANIMATION: + /* don't advance the anim iter here, or we could get frame changes between two + * exposes of different areas. + */ + + gdk_pixbuf_render_to_drawable_alpha (gdk_pixbuf_animation_iter_get_pixbuf (image->data.anim.iter), + widget->window, + image_bound.x - x, + image_bound.y - y, + image_bound.x, + image_bound.y, + image_bound.width, + image_bound.height, + GDK_PIXBUF_ALPHA_FULL, + 128, + GDK_RGB_DITHER_NORMAL, + 0, 0); + break; + default: break; } @@ -876,9 +1076,6 @@ gtk_image_clear (GtkImage *image) if (image->data.pixmap.mask) g_object_unref (G_OBJECT (image->data.pixmap.mask)); - image->data.pixmap.pixmap = NULL; - image->data.pixmap.mask = NULL; - break; case GTK_IMAGE_IMAGE: @@ -889,9 +1086,6 @@ gtk_image_clear (GtkImage *image) if (image->data.image.mask) g_object_unref (G_OBJECT (image->data.image.mask)); - image->data.image.image = NULL; - image->data.image.mask = NULL; - break; case GTK_IMAGE_PIXBUF: @@ -899,27 +1093,27 @@ gtk_image_clear (GtkImage *image) if (image->data.pixbuf.pixbuf) g_object_unref (G_OBJECT (image->data.pixbuf.pixbuf)); - image->data.pixbuf.pixbuf = NULL; - break; case GTK_IMAGE_STOCK: g_free (image->data.stock.stock_id); - - image->data.stock.stock_id = NULL; - image->data.stock.size = 0; break; case GTK_IMAGE_ICON_SET: if (image->data.icon_set.icon_set) gtk_icon_set_unref (image->data.icon_set.icon_set); - - image->data.icon_set.size = 0; - image->data.icon_set.icon_set = NULL; break; + + case GTK_IMAGE_ANIMATION: + if (image->data.anim.frame_timeout) + g_source_remove (image->data.anim.frame_timeout); + + if (image->data.anim.anim) + g_object_unref (G_OBJECT (image->data.anim.anim)); + break; case GTK_IMAGE_EMPTY: default: @@ -928,6 +1122,8 @@ gtk_image_clear (GtkImage *image) } image->storage_type = GTK_IMAGE_EMPTY; + + memset (&image->data, '\0', sizeof (image->data)); } static void diff --git a/gtk/gtkimage.h b/gtk/gtkimage.h index bc1a0c0a60..71c80dfd0a 100644 --- a/gtk/gtkimage.h +++ b/gtk/gtkimage.h @@ -52,6 +52,7 @@ typedef struct _GtkImageImageData GtkImageImageData; typedef struct _GtkImagePixbufData GtkImagePixbufData; typedef struct _GtkImageStockData GtkImageStockData; typedef struct _GtkImageIconSetData GtkImageIconSetData; +typedef struct _GtkImageAnimationData GtkImageAnimationData; struct _GtkImagePixmapData { @@ -82,6 +83,13 @@ struct _GtkImageIconSetData GtkIconSize size; }; +struct _GtkImageAnimationData +{ + GdkPixbufAnimation *anim; + GdkPixbufAnimationIter *iter; + guint frame_timeout; +}; + typedef enum { GTK_IMAGE_EMPTY, @@ -89,7 +97,8 @@ typedef enum GTK_IMAGE_IMAGE, GTK_IMAGE_PIXBUF, GTK_IMAGE_STOCK, - GTK_IMAGE_ICON_SET + GTK_IMAGE_ICON_SET, + GTK_IMAGE_ANIMATION } GtkImageType; struct _GtkImage @@ -105,6 +114,7 @@ struct _GtkImage GtkImagePixbufData pixbuf; GtkImageStockData stock; GtkImageIconSetData icon_set; + GtkImageAnimationData anim; } data; }; @@ -115,33 +125,36 @@ struct _GtkImageClass GtkType gtk_image_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap, - GdkBitmap *mask); -GtkWidget* gtk_image_new_from_image (GdkImage *image, - GdkBitmap *mask); -GtkWidget* gtk_image_new_from_file (const gchar *filename); -GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf); -GtkWidget* gtk_image_new_from_stock (const gchar *stock_id, - GtkIconSize size); -GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set, - GtkIconSize size); - -void gtk_image_set_from_pixmap (GtkImage *image, - GdkPixmap *pixmap, - GdkBitmap *mask); -void gtk_image_set_from_image (GtkImage *image, - GdkImage *gdk_image, - GdkBitmap *mask); -void gtk_image_set_from_file (GtkImage *image, - const gchar *filename); -void gtk_image_set_from_pixbuf (GtkImage *image, - GdkPixbuf *pixbuf); -void gtk_image_set_from_stock (GtkImage *image, - const gchar *stock_id, - GtkIconSize size); -void gtk_image_set_from_icon_set (GtkImage *image, - GtkIconSet *icon_set, - GtkIconSize size); +GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap, + GdkBitmap *mask); +GtkWidget* gtk_image_new_from_image (GdkImage *image, + GdkBitmap *mask); +GtkWidget* gtk_image_new_from_file (const gchar *filename); +GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf); +GtkWidget* gtk_image_new_from_stock (const gchar *stock_id, + GtkIconSize size); +GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set, + GtkIconSize size); +GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation); + +void gtk_image_set_from_pixmap (GtkImage *image, + GdkPixmap *pixmap, + GdkBitmap *mask); +void gtk_image_set_from_image (GtkImage *image, + GdkImage *gdk_image, + GdkBitmap *mask); +void gtk_image_set_from_file (GtkImage *image, + const gchar *filename); +void gtk_image_set_from_pixbuf (GtkImage *image, + GdkPixbuf *pixbuf); +void gtk_image_set_from_stock (GtkImage *image, + const gchar *stock_id, + GtkIconSize size); +void gtk_image_set_from_icon_set (GtkImage *image, + GtkIconSet *icon_set, + GtkIconSize size); +void gtk_image_set_from_animation (GtkImage *image, + GdkPixbufAnimation *animation); GtkImageType gtk_image_get_storage_type (GtkImage *image); @@ -158,6 +171,7 @@ void gtk_image_get_stock (GtkImage *image, void gtk_image_get_icon_set (GtkImage *image, GtkIconSet **icon_set, GtkIconSize *size); +GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image); #ifndef GTK_DISABLE_DEPRECATED diff --git a/gtk/gtkmarshal.list b/gtk/gtkmarshal.list index 12ec4108db..cb656a25cd 100644 --- a/gtk/gtkmarshal.list +++ b/gtk/gtkmarshal.list @@ -36,6 +36,7 @@ NONE:INT,INT NONE:NONE NONE:POINTER NONE:STRING,INT,POINTER +STRING:DOUBLE VOID:BOOLEAN VOID:BOXED VOID:BOXED,BOXED diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list index 12ec4108db..cb656a25cd 100644 --- a/gtk/gtkmarshalers.list +++ b/gtk/gtkmarshalers.list @@ -36,6 +36,7 @@ NONE:INT,INT NONE:NONE NONE:POINTER NONE:STRING,INT,POINTER +STRING:DOUBLE VOID:BOOLEAN VOID:BOXED VOID:BOXED,BOXED diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h index b9c27307b9..58fb89a386 100644 --- a/gtk/gtkrange.h +++ b/gtk/gtkrange.h @@ -91,13 +91,14 @@ struct _GtkRangeClass guint8 slider; guint8 step_forw; guint8 step_back; - + /* action signals for keybindings */ void (* move_slider) (GtkRange *range, GtkScrollType scroll, GtkTroughType trough); /* Completely broken virtual functions, please ignore */ + void (* draw_background) (GtkRange *range); void (* clear_background) (GtkRange *range); void (* draw_trough) (GtkRange *range); diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index a2769b2851..992cdfe41d 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -27,6 +27,7 @@ #include <math.h> #include "gtkintl.h" #include "gtkscale.h" +#include "gtkmarshal.h" enum { ARG_0, @@ -35,6 +36,12 @@ enum { ARG_VALUE_POS }; +enum { + FORMAT_VALUE, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; static void gtk_scale_class_init (GtkScaleClass *klass); static void gtk_scale_init (GtkScale *scale); @@ -78,6 +85,22 @@ gtk_scale_get_type (void) return scale_type; } +gboolean +single_string_accumulator (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy) +{ + gboolean continue_emission; + gchar *str; + + str = g_value_get_string (handler_return); + g_value_set_string (return_accu, str); + continue_emission = str == NULL; + + return continue_emission; +} + static void gtk_scale_class_init (GtkScaleClass *class) { @@ -104,6 +127,16 @@ gtk_scale_class_init (GtkScaleClass *class) GTK_ARG_READWRITE, ARG_VALUE_POS); + signals[FORMAT_VALUE] = + g_signal_newc ("format_value", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GtkScaleClass, format_value), + single_string_accumulator, NULL, + gtk_marshal_STRING__DOUBLE, + G_TYPE_STRING, 1, + G_TYPE_DOUBLE); + object_class->set_arg = gtk_scale_set_arg; object_class->get_arg = gtk_scale_get_arg; @@ -280,58 +313,27 @@ gtk_scale_get_value_size (GtkScale *scale, { PangoLayout *layout; PangoRectangle logical_rect; - gchar buffer[128]; - gdouble value; - gint digits; - gint i, j; + gchar *txt; range = GTK_RANGE (scale); layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL); - value = ABS (range->adjustment->lower); - if (value == 0) value = 1; - digits = log10 (value) + 1; - if (digits > 13) - digits = 13; - - i = 0; - if (range->adjustment->lower < 0) - buffer[i++] = '-'; - for (j = 0; j < digits; j++) - buffer[i++] = '0'; - if (GTK_RANGE (scale)->digits) - buffer[i++] = '.'; - for (j = 0; j < GTK_RANGE (scale)->digits; j++) - buffer[i++] = '0'; - buffer[i] = '\0'; - - pango_layout_set_text (layout, buffer, i); + txt = _gtk_scale_format_value (scale, range->adjustment->lower); + pango_layout_set_text (layout, txt, -1); + g_free (txt); + pango_layout_get_pixel_extents (layout, NULL, &logical_rect); if (width) *width = logical_rect.width; if (height) - *height = logical_rect.width; + *height = logical_rect.height; + + txt = _gtk_scale_format_value (scale, range->adjustment->upper); + pango_layout_set_text (layout, txt, -1); + g_free (txt); - value = ABS (range->adjustment->upper); - if (value == 0) value = 1; - digits = log10 (value) + 1; - if (digits > 13) - digits = 13; - - i = 0; - if (range->adjustment->upper < 0) - buffer[i++] = '-'; - for (j = 0; j < digits; j++) - buffer[i++] = '0'; - if (GTK_RANGE (scale)->digits) - buffer[i++] = '.'; - for (j = 0; j < GTK_RANGE (scale)->digits; j++) - buffer[i++] = '0'; - buffer[i] = '\0'; - - pango_layout_set_text (layout, buffer, i); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); if (width) @@ -383,3 +385,32 @@ gtk_scale_draw_background (GtkRange *range) gtk_scale_draw_value (GTK_SCALE (range)); } + +/** + * _gtk_scale_format_value: + * @scale: a #GtkScale + * @value: adjustment value + * + * Emits "format_value" signal to format the value, if no user + * signal handlers, falls back to a default format. + * + * Return value: formatted value + **/ +gchar* +_gtk_scale_format_value (GtkScale *scale, + gdouble value) +{ + gchar *fmt = NULL; + + g_signal_emit (G_OBJECT (scale), + signals[FORMAT_VALUE], + 0, + value, + &fmt); + + if (fmt) + return fmt; + else + return g_strdup_printf ("%0.*f", GTK_RANGE (scale)->digits, + value); +} diff --git a/gtk/gtkscale.h b/gtk/gtkscale.h index fd9e97446d..b6cd719547 100644 --- a/gtk/gtkscale.h +++ b/gtk/gtkscale.h @@ -61,6 +61,9 @@ struct _GtkScaleClass GtkRangeClass parent_class; gint value_spacing; + + gchar* (* format_value) (GtkRange *range, + gdouble value); void (* draw_value) (GtkScale *scale); }; @@ -79,6 +82,9 @@ void gtk_scale_get_value_size (GtkScale *scale, void gtk_scale_draw_value (GtkScale *scale); +gchar *_gtk_scale_format_value (GtkScale *scale, + gdouble value); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 1074ca0f9a..2e30d026ac 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -2106,6 +2106,127 @@ gtk_text_buffer_remove_tag_by_name (GtkTextBuffer *buffer, gtk_text_buffer_emit_tag (buffer, tag, FALSE, start, end); } +static gint +pointer_cmp (gconstpointer a, + gconstpointer b) +{ + if (a < b) + return -1; + else if (a > b) + return 1; + else + return 0; +} + +/** + * gtk_text_buffer_remove_all_tags: + * @buffer: a #GtkTextBuffer + * @start: one bound of range to be untagged + * @end: other bound of range to be untagged + * + * Removes all tags in the range between @start and @end. Be careful + * with this function; it could remove tags added in code unrelated to + * the code you're currently writing. That is, using this function is + * probably a bad idea if you have two or more unrelated code sections + * that add tags. + **/ +void +gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer, + const GtkTextIter *start, + const GtkTextIter *end) +{ + GtkTextIter first, second, tmp; + GSList *tags; + GSList *tmp_list; + GSList *prev; + GtkTextTag *tag; + + g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer)); + g_return_if_fail (start != NULL); + g_return_if_fail (end != NULL); + + first = *start; + second = *end; + + gtk_text_iter_reorder (&first, &second); + + /* Get all tags turned on at the start */ + tags = gtk_text_iter_get_tags (&first); + + /* Find any that are toggled on within the range */ + tmp = first; + while (gtk_text_iter_forward_to_tag_toggle (&tmp, NULL)) + { + GSList *toggled; + GSList *tmp_list2; + + if (gtk_text_iter_compare (&tmp, &second) >= 0) + break; /* past the end of the range */ + + toggled = gtk_text_iter_get_toggled_tags (&tmp, TRUE); + + /* We could end up with a really big-ass list here. + * Fix it someday. + */ + tmp_list2 = toggled; + while (tmp_list2 != NULL) + { + tags = g_slist_prepend (tags, tmp_list2->data); + + tmp_list2 = g_slist_next (tmp_list2); + } + + g_slist_free (toggled); + } + + /* Sort the list */ + tags = g_slist_sort (tags, pointer_cmp); + + /* Strip duplicates */ + tag = NULL; + prev = NULL; + tmp_list = tags; + while (tmp_list != NULL) + { + if (tag == tmp_list->data) + { + /* duplicate */ + if (prev) + prev->next = tmp_list->next; + + tmp_list->next = NULL; + + g_slist_free (tmp_list); + + tmp_list = prev->next; + /* prev is unchanged */ + } + else + { + /* not a duplicate */ + tag = GTK_TEXT_TAG (tmp_list->data); + prev = tmp_list; + tmp_list = tmp_list->next; + } + } + + g_list_foreach (tags, (GFunc) g_object_ref, NULL); + + tmp_list = tags; + while (tmp_list != NULL) + { + tag = GTK_TEXT_TAG (tmp_list->data); + + gtk_text_buffer_remove_tag (buffer, tag, &first, &second); + + tmp_list = tmp_list->next; + } + + g_list_foreach (tags, (GFunc) g_object_unref, NULL); + + g_slist_free (tags); +} + /* * Obtain various iterators diff --git a/gtk/gtktextbuffer.h b/gtk/gtktextbuffer.h index b6f801f119..4368d242aa 100644 --- a/gtk/gtktextbuffer.h +++ b/gtk/gtktextbuffer.h @@ -266,6 +266,9 @@ void gtk_text_buffer_remove_tag_by_name (GtkTextBuffer *buffer, const gchar *name, const GtkTextIter *start, const GtkTextIter *end); +void gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer, + const GtkTextIter *start, + const GtkTextIter *end); /* You can either ignore the return value, or use it to diff --git a/gtk/gtktextiter.c b/gtk/gtktextiter.c index 241529d389..1d53032146 100644 --- a/gtk/gtktextiter.c +++ b/gtk/gtktextiter.c @@ -1511,7 +1511,7 @@ gtk_text_iter_is_end (const GtkTextIter *iter) } /** - * gtk_text_iter_is_first: + * gtk_text_iter_is_start: * @iter: an iterator * * Returns TRUE if @iter is the first iterator in the buffer, that is @@ -1520,7 +1520,7 @@ gtk_text_iter_is_end (const GtkTextIter *iter) * Return value: whether @iter is the first in the buffer **/ gboolean -gtk_text_iter_is_first (const GtkTextIter *iter) +gtk_text_iter_is_start (const GtkTextIter *iter) { return gtk_text_iter_get_offset (iter) == 0; } @@ -4253,7 +4253,7 @@ lines_window_init (LinesWindow *win, /* If we start on line 1, there are 2 lines to search (0 and 1), so * n_lines can be 2. */ - if (gtk_text_iter_is_first (start) || + if (gtk_text_iter_is_start (start) || gtk_text_iter_get_line (start) + 1 < win->n_lines) { /* Already at the end, or not enough lines to match */ diff --git a/gtk/gtktextiter.h b/gtk/gtktextiter.h index 00285e287b..8a883f9b23 100644 --- a/gtk/gtktextiter.h +++ b/gtk/gtktextiter.h @@ -108,9 +108,10 @@ GSList * gtk_text_iter_get_marks (const GtkTextIter *iter); GtkTextChildAnchor* gtk_text_iter_get_child_anchor (const GtkTextIter *iter); /* Return list of tags toggled at this point (toggled_on determines - whether the list is of on-toggles or off-toggles) */ + * whether the list is of on-toggles or off-toggles) + */ GSList *gtk_text_iter_get_toggled_tags (const GtkTextIter *iter, - gboolean toggled_on); + gboolean toggled_on); gboolean gtk_text_iter_begins_tag (const GtkTextIter *iter, GtkTextTag *tag); @@ -145,7 +146,7 @@ gboolean gtk_text_iter_get_attributes (const GtkTextIter *iter, GtkTextAttributes *values); gchar* gtk_text_iter_get_language (const GtkTextIter *iter); gboolean gtk_text_iter_is_end (const GtkTextIter *iter); -gboolean gtk_text_iter_is_first (const GtkTextIter *iter); +gboolean gtk_text_iter_is_start (const GtkTextIter *iter); /* * Moving around the buffer diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 1355ef8fff..208fa8c0ea 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -1280,6 +1280,16 @@ add_text_attrs (GtkTextLayout *layout, attr->end_index = start + byte_count; pango_attr_list_insert (attrs, attr); + + if (style->font_scale != 1.0) + { + attr = pango_attr_scale_new (style->font_scale); + + attr->start_index = start; + attr->end_index = start + byte_count; + + pango_attr_list_insert (attrs, attr); + } } static void diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c index a652432301..c149c4edad 100644 --- a/gtk/gtktexttag.c +++ b/gtk/gtktexttag.c @@ -85,6 +85,7 @@ enum { PROP_STRETCH, PROP_SIZE, PROP_SIZE_POINTS, + PROP_SCALE, PROP_PIXELS_ABOVE_LINES, PROP_PIXELS_BELOW_LINES, PROP_PIXELS_INSIDE_WRAP, @@ -114,6 +115,7 @@ enum { PROP_WEIGHT_SET, PROP_STRETCH_SET, PROP_SIZE_SET, + PROP_SCALE_SET, PROP_PIXELS_ABOVE_LINES_SET, PROP_PIXELS_BELOW_LINES_SET, PROP_PIXELS_INSIDE_WRAP_SET, @@ -350,6 +352,16 @@ gtk_text_tag_class_init (GtkTextTagClass *klass) G_PARAM_READABLE | G_PARAM_WRITABLE)); g_object_class_install_property (object_class, + PROP_SCALE, + g_param_spec_double ("scale", + _("Font scale"), + _("Font scale"), + 0.0, + G_MAXDOUBLE, + 1.0, + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + g_object_class_install_property (object_class, PROP_SIZE_POINTS, g_param_spec_double ("size_points", _("Font points"), @@ -543,6 +555,10 @@ gtk_text_tag_class_init (GtkTextTagClass *klass) _("Font size set"), _("Whether this tag affects the font size")); + ADD_SET_PROP ("scale_set", PROP_SCALE_SET, + _("Font scale set"), + _("Whether this tag scales the font size by a factor")); + ADD_SET_PROP ("justification_set", PROP_JUSTIFICATION_SET, _("Justification set"), _("Whether this tag affects paragraph justification")); @@ -963,6 +979,12 @@ gtk_text_tag_set_property (GObject *object, size_changed = TRUE; break; + case PROP_SCALE: + text_tag->values->font_scale = g_value_get_double (value); + text_tag->scale_set = TRUE; + size_changed = TRUE; + break; + case PROP_SIZE_POINTS: text_tag->values->font.size = g_value_get_double (value) * PANGO_SCALE; text_tag->size_set = TRUE; @@ -1151,6 +1173,11 @@ gtk_text_tag_set_property (GObject *object, text_tag->size_set = g_value_get_boolean (value); size_changed = TRUE; break; + + case PROP_SCALE_SET: + text_tag->scale_set = g_value_get_boolean (value); + size_changed = TRUE; + break; case PROP_PIXELS_ABOVE_LINES_SET: text_tag->pixels_above_lines_set = g_value_get_boolean (value); @@ -1332,10 +1359,14 @@ gtk_text_tag_get_property (GObject *object, case PROP_SIZE: g_value_set_int (value, tag->values->font.size); break; - + case PROP_SIZE_POINTS: g_value_set_double (value, ((double)tag->values->font.size) / (double)PANGO_SCALE); break; + + case PROP_SCALE: + g_value_set_double (value, tag->values->font_scale); + break; case PROP_PIXELS_ABOVE_LINES: g_value_set_int (value, tag->values->pixels_above_lines); @@ -1445,6 +1476,10 @@ gtk_text_tag_get_property (GObject *object, case PROP_SIZE_SET: g_value_set_boolean (value, tag->size_set); break; + + case PROP_SCALE_SET: + g_value_set_boolean (value, tag->scale_set); + break; case PROP_PIXELS_ABOVE_LINES_SET: g_value_set_boolean (value, tag->pixels_above_lines_set); @@ -1724,6 +1759,8 @@ gtk_text_attributes_new (void) values->language = gtk_get_default_language (); + values->font_scale = 1.0; + return values; } @@ -1965,6 +2002,10 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest, if (tag->size_set) dest->font.size = vals->font.size; + /* multiply all the scales together to get a composite */ + if (tag->scale_set) + dest->font_scale *= vals->font_scale; + if (tag->justification_set) dest->justification = vals->justification; @@ -2038,6 +2079,7 @@ _gtk_text_tag_affects_size (GtkTextTag *tag) tag->variant_set || tag->weight_set || tag->size_set || + tag->scale_set || tag->stretch_set || tag->justification_set || tag->left_margin_set || diff --git a/gtk/gtktexttag.h b/gtk/gtktexttag.h index ea30059b75..f75a1760b0 100644 --- a/gtk/gtktexttag.h +++ b/gtk/gtktexttag.h @@ -60,6 +60,7 @@ struct _GtkTextTag guint weight_set : 1; guint stretch_set : 1; guint size_set : 1; + guint scale_set : 1; guint fg_stipple_set : 1; guint justification_set : 1; guint left_margin_set : 1; @@ -148,6 +149,8 @@ struct _GtkTextAttributes /* Individual chunks of this can be set/unset as a group */ PangoFontDescription font; + gdouble font_scale; + gint left_margin; gint indent; diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 26aa7c6980..8bb7314b47 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -506,6 +506,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass) GTK_ARG_READWRITE, ARG_PIXELS_INSIDE_WRAP); gtk_object_add_arg_type ("GtkTextView::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE); + gtk_object_add_arg_type ("GtkTextView::wrap_mode", GTK_TYPE_WRAP_MODE, GTK_ARG_READWRITE, ARG_WRAP_MODE); gtk_object_add_arg_type ("GtkTextView::justify", GTK_TYPE_JUSTIFICATION, diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index 72b8b209aa..be31ec3378 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -532,7 +532,6 @@ gtk_vscale_draw_value (GtkScale *scale) { GtkStateType state_type; GtkWidget *widget; - gchar buffer[32]; gint width, height; gint x, y; @@ -545,10 +544,14 @@ gtk_vscale_draw_value (GtkScale *scale) { PangoLayout *layout; PangoRectangle logical_rect; + gchar *txt; + + txt = _gtk_scale_format_value (scale, + GTK_RANGE (scale)->adjustment->value); + + layout = gtk_widget_create_pango_layout (widget, txt); + g_free (txt); - sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); - - layout = gtk_widget_create_pango_layout (widget, buffer); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); switch (scale->value_pos) |