[goocanvas] 2009-06-29 Damon Chaplin <damon gnome org>
- From: Damon Chaplin <damon src gnome org>
- To: svn-commits-list gnome org
- Subject: [goocanvas] 2009-06-29 Damon Chaplin <damon gnome org>
- Date: Mon, 29 Jun 2009 15:34:59 +0000 (UTC)
commit 4c0838b8b0369e37dea2fa5854e3ed49772240f3
Author: Damon Chaplin <damon gnome org>
Date: Mon Jun 29 16:32:07 2009 +0100
2009-06-29 Damon Chaplin <damon gnome org>
* Released GooCanvas 0.15
2009-06-29 Damon Chaplin <damon gnome org>
* src/goocanvasimage.c: added "scale-to-fit" property, which scales
the image to fit the "width" and "height" settings.
* demo/units-demo.c:
* demo/mv-demo.c (plant_flower):
* demo/demo.c (plant_flower): test "scale-to-fit" property.
.gitignore | 14 +++++++++
ChangeLog | 13 +++++++++
configure.in | 6 ++--
demo/demo.c | 5 ++-
demo/mv-demo.c | 5 ++-
demo/units-demo.c | 35 ++++++++++++++++++++---
po/en_GB.po | 30 +++++++++++++-------
po/es.po | 31 +++++++++++++-------
po/goocanvas.pot | 30 +++++++++++++-------
po/ja.po | 31 +++++++++++++-------
src/goocanvasimage.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++-
11 files changed, 216 insertions(+), 58 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 99c7eeb..a0a6d03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,3 +48,17 @@ Makefile.in
/src/stamp-goocanvasenumtypes.h
/src/stamp-goocanvasmarshal.h
/stamp-h1
+/docs/goocanvas-decl-list.txt
+/docs/goocanvas-decl.txt
+/docs/goocanvas-undeclared.txt
+/docs/goocanvas-undocumented.txt
+/docs/goocanvas-unused.txt
+/docs/goocanvas.args
+/docs/goocanvas.hierarchy
+/docs/goocanvas.interfaces
+/docs/goocanvas.prerequisites
+/docs/goocanvas.signals
+/docs/*.stamp
+/docs/html
+/docs/xml
+/docs/tmpl/goo*.sgml
diff --git a/ChangeLog b/ChangeLog
index 1d52735..add0375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-06-29 Damon Chaplin <damon gnome org>
+
+ * Released GooCanvas 0.15
+
+2009-06-29 Damon Chaplin <damon gnome org>
+
+ * src/goocanvasimage.c: added "scale-to-fit" property, which scales
+ the image to fit the "width" and "height" settings.
+
+ * demo/units-demo.c:
+ * demo/mv-demo.c (plant_flower):
+ * demo/demo.c (plant_flower): test "scale-to-fit" property.
+
2009-05-07 Damon Chaplin <damon gnome org>
* src/goocanvasatk.c: fixed GooCanvasWidgetAccessible's G_DEFINE_TYPE
diff --git a/configure.in b/configure.in
index 0ec0c82..83d498d 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
-AC_INIT(goocanvas, 0.14)
+AC_INIT(goocanvas, 0.15)
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(src/goocanvas.c)
AC_CONFIG_HEADERS(config.h)
@@ -12,8 +12,8 @@ AM_INIT_AUTOMAKE
# If interfaces changed but it is backwards compatible: AGE++, else AGE=0.
# i.e. the library supports interfaces CURRENT - AGE up to CURRENT.
# if two libraries have identical CURRENT and AGE, then newest REVISION used.
-CURRENT=6
-AGE=3
+CURRENT=7
+AGE=4
REVISION=0
LT_VERSION_INFO="$CURRENT:$REVISION:$AGE"
diff --git a/demo/demo.c b/demo/demo.c
index f369a96..2c44e18 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -1321,8 +1321,9 @@ plant_flower (GooCanvasItem *root, double x, double y, GtkAnchorType anchor)
image = goo_canvas_image_new (root, NULL, x, y,
"pattern", pattern,
- "width", w,
- "height", h,
+ "width", w * 1.5,
+ "height", h * 2,
+ "scale-to-fit", TRUE,
NULL);
cairo_pattern_destroy (pattern);
setup_item_signals (image);
diff --git a/demo/mv-demo.c b/demo/mv-demo.c
index 3820485..ddb6472 100644
--- a/demo/mv-demo.c
+++ b/demo/mv-demo.c
@@ -1189,8 +1189,9 @@ plant_flower (GooCanvasItemModel *root,
image = goo_canvas_image_model_new (root, NULL, x, y,
"pattern", pattern,
- "width", w,
- "height", h,
+ "width", w * 1.5,
+ "height", h * 2,
+ "scale-to-fit", TRUE,
NULL);
cairo_pattern_destroy (pattern);
}
diff --git a/demo/units-demo.c b/demo/units-demo.c
index f3716a5..4a28e8b 100644
--- a/demo/units-demo.c
+++ b/demo/units-demo.c
@@ -1,6 +1,9 @@
#include <stdlib.h>
#include <goocanvas.h>
+cairo_pattern_t *flower_pattern;
+gdouble flower_width, flower_height;
+
static gboolean
on_motion_notify (GooCanvasItem *item,
@@ -24,22 +27,30 @@ setup_canvas (GtkWidget *canvas,
GooCanvasItem *root, *item;
gchar buffer[256], font_desc[64];
double *d;
- double data[4][8] = {
+ double data[4][12] = {
/* Pixels */
{ 100, 100, 200, 20, 10,
- 200, 310, 24 },
+ 200, 310, 24,
+ 310, 100, 20, 20
+ },
/* Points */
{ 100, 100, 200, 20, 10,
- 200, 310, 24 },
+ 200, 310, 24,
+ 310, 100, 20, 20
+ },
/* Inches */
{ 1, 1, 3, 0.5, 0.16,
- 3, 4, 0.3 },
+ 3, 4, 0.3,
+ 4.2, 1, 0.5, 0.5
+ },
/* MM */
{ 30, 30, 100, 10, 5,
- 80, 60, 10 }
+ 80, 60, 10,
+ 135, 30, 10, 10
+ }
};
d = data[units];
@@ -65,6 +76,13 @@ setup_canvas (GtkWidget *canvas,
GTK_ANCHOR_CENTER,
"font", font_desc,
NULL);
+
+ item = goo_canvas_image_new (root, NULL, d[8], d[9],
+ "pattern", flower_pattern,
+ "width", d[10],
+ "height", d[11],
+ "scale-to-fit", TRUE,
+ NULL);
}
@@ -140,6 +158,7 @@ int
main (int argc, char *argv[])
{
GtkWidget *window, *notebook;
+ cairo_surface_t *surface;
gtk_set_locale ();
gtk_init (&argc, &argv);
@@ -154,6 +173,12 @@ main (int argc, char *argv[])
gtk_widget_show (notebook);
gtk_container_add (GTK_CONTAINER (window), notebook);
+ surface = cairo_image_surface_create_from_png ("flower.png");
+ flower_width = cairo_image_surface_get_width (surface);
+ flower_height = cairo_image_surface_get_height (surface);
+ flower_pattern = cairo_pattern_create_for_surface (surface);
+ cairo_surface_destroy (surface);
+
gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
create_canvas (GTK_UNIT_PIXEL, "pixels"),
gtk_label_new ("Pixels"));
diff --git a/po/en_GB.po b/po/en_GB.po
index 9cb661f..c9bdfe4 100644
--- a/po/en_GB.po
+++ b/po/en_GB.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GooCanvas CVS\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-03-15 16:57+0000\n"
+"POT-Creation-Date: 2009-06-29 16:23+0100\n"
"PO-Revision-Date: 2006-04-24 16:26+0100\n"
"Last-Translator: Damon Chaplin <damon gnome org>\n"
"Language-Team: \n"
@@ -217,7 +217,7 @@ msgid "The y coordinate of the top of the ellipse"
msgstr ""
#: src/goocanvasellipse.c:123 src/goocanvasgrid.c:124 src/goocanvasgroup.c:106
-#: src/goocanvasimage.c:95 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
+#: src/goocanvasimage.c:107 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
#: src/goocanvasrect.c:76 src/goocanvastext.c:141 src/goocanvaswidget.c:572
msgid "Width"
msgstr ""
@@ -227,7 +227,7 @@ msgid "The width of the ellipse"
msgstr ""
#: src/goocanvasellipse.c:130 src/goocanvasgrid.c:131 src/goocanvasgroup.c:114
-#: src/goocanvasimage.c:102 src/goocanvaspath.c:100
+#: src/goocanvasimage.c:114 src/goocanvaspath.c:100
#: src/goocanvaspolyline.c:214 src/goocanvasrect.c:83 src/goocanvastext.c:149
#: src/goocanvaswidget.c:580
msgid "Height"
@@ -433,35 +433,43 @@ msgstr ""
msgid "The height of the group, or -1 to use the default height"
msgstr ""
-#: src/goocanvasimage.c:72
+#: src/goocanvasimage.c:84
msgid "Pattern"
msgstr ""
-#: src/goocanvasimage.c:73
+#: src/goocanvasimage.c:85
msgid "The cairo pattern to paint"
msgstr ""
-#: src/goocanvasimage.c:80
+#: src/goocanvasimage.c:92
msgid "The x coordinate of the image"
msgstr ""
-#: src/goocanvasimage.c:88
+#: src/goocanvasimage.c:100
msgid "The y coordinate of the image"
msgstr ""
-#: src/goocanvasimage.c:96
+#: src/goocanvasimage.c:108
msgid "The width of the image"
msgstr ""
-#: src/goocanvasimage.c:103
+#: src/goocanvasimage.c:115
msgid "The height of the image"
msgstr ""
-#: src/goocanvasimage.c:109
+#: src/goocanvasimage.c:121
+msgid "Scale To Fit"
+msgstr ""
+
+#: src/goocanvasimage.c:122
+msgid "If the image is scaled to fit the width and height settings"
+msgstr ""
+
+#: src/goocanvasimage.c:128
msgid "Pixbuf"
msgstr ""
-#: src/goocanvasimage.c:110
+#: src/goocanvasimage.c:129
msgid "The GdkPixbuf to display"
msgstr ""
diff --git a/po/es.po b/po/es.po
index 1f35f7e..c9bceee 100644
--- a/po/es.po
+++ b/po/es.po
@@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GooCanvas CVS\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-03-15 16:57+0000\n"
+"POT-Creation-Date: 2009-06-29 16:23+0100\n"
"PO-Revision-Date: 2006-04-24 16:26+0100\n"
"Last-Translator: Rafael Villar Burke <pachi rvburke com>\n"
"Language-Team: \n"
@@ -235,7 +235,7 @@ msgid "The y coordinate of the top of the ellipse"
msgstr "Coordenada y del centro de la elipse"
#: src/goocanvasellipse.c:123 src/goocanvasgrid.c:124 src/goocanvasgroup.c:106
-#: src/goocanvasimage.c:95 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
+#: src/goocanvasimage.c:107 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
#: src/goocanvasrect.c:76 src/goocanvastext.c:141 src/goocanvaswidget.c:572
msgid "Width"
msgstr "Ancho"
@@ -246,7 +246,7 @@ msgid "The width of the ellipse"
msgstr "Ancho de la imagen"
#: src/goocanvasellipse.c:130 src/goocanvasgrid.c:131 src/goocanvasgroup.c:114
-#: src/goocanvasimage.c:102 src/goocanvaspath.c:100
+#: src/goocanvasimage.c:114 src/goocanvaspath.c:100
#: src/goocanvaspolyline.c:214 src/goocanvasrect.c:83 src/goocanvastext.c:149
#: src/goocanvaswidget.c:580
msgid "Height"
@@ -488,35 +488,44 @@ msgstr "Ancho solicitado de la tabla, o -1 para usar el ancho predeterminado"
msgid "The height of the group, or -1 to use the default height"
msgstr "Altura solicitada de la tabla, o -1 para usar la altura predefinida"
-#: src/goocanvasimage.c:72
+#: src/goocanvasimage.c:84
msgid "Pattern"
msgstr "Patrón"
-#: src/goocanvasimage.c:73
+#: src/goocanvasimage.c:85
msgid "The cairo pattern to paint"
msgstr "Patrón cairo para dibujar"
-#: src/goocanvasimage.c:80
+#: src/goocanvasimage.c:92
msgid "The x coordinate of the image"
msgstr "Coordenada x de la imagen"
-#: src/goocanvasimage.c:88
+#: src/goocanvasimage.c:100
msgid "The y coordinate of the image"
msgstr "Coordenada y de la imagen"
-#: src/goocanvasimage.c:96
+#: src/goocanvasimage.c:108
msgid "The width of the image"
msgstr "Ancho de la imagen"
-#: src/goocanvasimage.c:103
+#: src/goocanvasimage.c:115
msgid "The height of the image"
msgstr "Altura de la la imagen"
-#: src/goocanvasimage.c:109
+#: src/goocanvasimage.c:121
+#, fuzzy
+msgid "Scale To Fit"
+msgstr "Escala"
+
+#: src/goocanvasimage.c:122
+msgid "If the image is scaled to fit the width and height settings"
+msgstr ""
+
+#: src/goocanvasimage.c:128
msgid "Pixbuf"
msgstr "Pixbuf"
-#: src/goocanvasimage.c:110
+#: src/goocanvasimage.c:129
msgid "The GdkPixbuf to display"
msgstr "GdkPixbuf para mostrar"
diff --git a/po/goocanvas.pot b/po/goocanvas.pot
index 3e17696..7be1805 100644
--- a/po/goocanvas.pot
+++ b/po/goocanvas.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-03-15 16:57+0000\n"
+"POT-Creation-Date: 2009-06-29 16:23+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL ADDRESS>\n"
"Language-Team: LANGUAGE <LL li org>\n"
@@ -218,7 +218,7 @@ msgid "The y coordinate of the top of the ellipse"
msgstr ""
#: src/goocanvasellipse.c:123 src/goocanvasgrid.c:124 src/goocanvasgroup.c:106
-#: src/goocanvasimage.c:95 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
+#: src/goocanvasimage.c:107 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
#: src/goocanvasrect.c:76 src/goocanvastext.c:141 src/goocanvaswidget.c:572
msgid "Width"
msgstr ""
@@ -228,7 +228,7 @@ msgid "The width of the ellipse"
msgstr ""
#: src/goocanvasellipse.c:130 src/goocanvasgrid.c:131 src/goocanvasgroup.c:114
-#: src/goocanvasimage.c:102 src/goocanvaspath.c:100
+#: src/goocanvasimage.c:114 src/goocanvaspath.c:100
#: src/goocanvaspolyline.c:214 src/goocanvasrect.c:83 src/goocanvastext.c:149
#: src/goocanvaswidget.c:580
msgid "Height"
@@ -434,35 +434,43 @@ msgstr ""
msgid "The height of the group, or -1 to use the default height"
msgstr ""
-#: src/goocanvasimage.c:72
+#: src/goocanvasimage.c:84
msgid "Pattern"
msgstr ""
-#: src/goocanvasimage.c:73
+#: src/goocanvasimage.c:85
msgid "The cairo pattern to paint"
msgstr ""
-#: src/goocanvasimage.c:80
+#: src/goocanvasimage.c:92
msgid "The x coordinate of the image"
msgstr ""
-#: src/goocanvasimage.c:88
+#: src/goocanvasimage.c:100
msgid "The y coordinate of the image"
msgstr ""
-#: src/goocanvasimage.c:96
+#: src/goocanvasimage.c:108
msgid "The width of the image"
msgstr ""
-#: src/goocanvasimage.c:103
+#: src/goocanvasimage.c:115
msgid "The height of the image"
msgstr ""
-#: src/goocanvasimage.c:109
+#: src/goocanvasimage.c:121
+msgid "Scale To Fit"
+msgstr ""
+
+#: src/goocanvasimage.c:122
+msgid "If the image is scaled to fit the width and height settings"
+msgstr ""
+
+#: src/goocanvasimage.c:128
msgid "Pixbuf"
msgstr ""
-#: src/goocanvasimage.c:110
+#: src/goocanvasimage.c:129
msgid "The GdkPixbuf to display"
msgstr ""
diff --git a/po/ja.po b/po/ja.po
index 408ea3e..436d766 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: GooCanvas CVS\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-03-15 16:57+0000\n"
+"POT-Creation-Date: 2009-06-29 16:23+0100\n"
"PO-Revision-Date: 2008-04-28 20:42+0900\n"
"Last-Translator: kou cozmixng org <kou cozmixng org>\n"
"Language-Team:\n"
@@ -221,7 +221,7 @@ msgid "The y coordinate of the top of the ellipse"
msgstr "æ¥?å??ã?®ä¸å¿?ã?® Y 座æ¨?"
#: src/goocanvasellipse.c:123 src/goocanvasgrid.c:124 src/goocanvasgroup.c:106
-#: src/goocanvasimage.c:95 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
+#: src/goocanvasimage.c:107 src/goocanvaspath.c:93 src/goocanvaspolyline.c:207
#: src/goocanvasrect.c:76 src/goocanvastext.c:141 src/goocanvaswidget.c:572
msgid "Width"
msgstr "å¹?"
@@ -232,7 +232,7 @@ msgid "The width of the ellipse"
msgstr "ç?»å??ã?®å¹?"
#: src/goocanvasellipse.c:130 src/goocanvasgrid.c:131 src/goocanvasgroup.c:114
-#: src/goocanvasimage.c:102 src/goocanvaspath.c:100
+#: src/goocanvasimage.c:114 src/goocanvaspath.c:100
#: src/goocanvaspolyline.c:214 src/goocanvasrect.c:83 src/goocanvastext.c:149
#: src/goocanvaswidget.c:580
msgid "Height"
@@ -477,35 +477,44 @@ msgstr "è¦?æ±?ã??ã??表ã?®å¹?ã??ã??ã??ã?©ã?«ã??ã?®å¹?ã??使ã??ã?ªã?? -1 ã?§ã??"
msgid "The height of the group, or -1 to use the default height"
msgstr "è¦?æ±?ã??ã??表ã?®é«?ã??ã??ã??ã??ã?©ã?«ã??ã?®é«?ã??ã??使ã??ã?ªã?? -1 ã?§ã??"
-#: src/goocanvasimage.c:72
+#: src/goocanvasimage.c:84
msgid "Pattern"
msgstr "ã??ã?¿ã?¼ã?³"
-#: src/goocanvasimage.c:73
+#: src/goocanvasimage.c:85
msgid "The cairo pattern to paint"
msgstr "å¡?ã??ã?¤ã?¶ã??ç?¨ã?® cairo ã?®ã??ã?¿ã?¼ã?³"
-#: src/goocanvasimage.c:80
+#: src/goocanvasimage.c:92
msgid "The x coordinate of the image"
msgstr "ç?»å??ã?® X 座æ¨?"
-#: src/goocanvasimage.c:88
+#: src/goocanvasimage.c:100
msgid "The y coordinate of the image"
msgstr "ç?»å??ã?® Y 座æ¨?"
-#: src/goocanvasimage.c:96
+#: src/goocanvasimage.c:108
msgid "The width of the image"
msgstr "ç?»å??ã?®å¹?"
-#: src/goocanvasimage.c:103
+#: src/goocanvasimage.c:115
msgid "The height of the image"
msgstr "ç?»å??ã?®é«?ã??"
-#: src/goocanvasimage.c:109
+#: src/goocanvasimage.c:121
+#, fuzzy
+msgid "Scale To Fit"
+msgstr "Xæ?¹å??ã?®ã?¹ã?±ã?¼ã?«"
+
+#: src/goocanvasimage.c:122
+msgid "If the image is scaled to fit the width and height settings"
+msgstr ""
+
+#: src/goocanvasimage.c:128
msgid "Pixbuf"
msgstr "Pixbuf"
-#: src/goocanvasimage.c:110
+#: src/goocanvasimage.c:129
msgid "The GdkPixbuf to display"
msgstr "表示ã??ã??GdkPixbuf"
diff --git a/src/goocanvasimage.c b/src/goocanvasimage.c
index 4ee2426..a91ae62 100644
--- a/src/goocanvasimage.c
+++ b/src/goocanvasimage.c
@@ -33,6 +33,17 @@
#include "goocanvasutils.h"
+typedef struct _GooCanvasImagePrivate GooCanvasImagePrivate;
+struct _GooCanvasImagePrivate {
+ gboolean scale_to_fit;
+};
+
+#define GOO_CANVAS_IMAGE_GET_PRIVATE(image) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((image), GOO_TYPE_CANVAS_IMAGE, GooCanvasImagePrivate))
+#define GOO_CANVAS_IMAGE_MODEL_GET_PRIVATE(image) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((image), GOO_TYPE_CANVAS_IMAGE_MODEL, GooCanvasImagePrivate))
+
+
enum {
PROP_0,
@@ -41,6 +52,7 @@ enum {
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
+ PROP_SCALE_TO_FIT,
/* Convenience properties. */
PROP_PIXBUF
@@ -104,6 +116,13 @@ goo_canvas_image_install_common_properties (GObjectClass *gobject_class)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_SCALE_TO_FIT,
+ g_param_spec_boolean ("scale-to-fit",
+ _("Scale To Fit"),
+ _("If the image is scaled to fit the width and height settings"),
+ FALSE,
+ G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_class, PROP_PIXBUF,
g_param_spec_object ("pixbuf",
_("Pixbuf"),
@@ -113,6 +132,27 @@ goo_canvas_image_install_common_properties (GObjectClass *gobject_class)
}
+/* Gets the private data to use, from the model or from the item itself. */
+static GooCanvasImagePrivate*
+goo_canvas_image_get_private (gpointer object)
+{
+ GooCanvasItemSimple *simple;
+
+ if (GOO_IS_CANVAS_IMAGE (object))
+ {
+ simple = (GooCanvasItemSimple*) object;
+ if (simple->model)
+ return GOO_CANVAS_IMAGE_MODEL_GET_PRIVATE (simple->model);
+ else
+ return GOO_CANVAS_IMAGE_GET_PRIVATE (object);
+ }
+ else
+ {
+ return GOO_CANVAS_IMAGE_MODEL_GET_PRIVATE (object);
+ }
+}
+
+
static void
goo_canvas_image_init (GooCanvasImage *image)
{
@@ -226,6 +266,8 @@ goo_canvas_image_get_common_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
+ GooCanvasImagePrivate *priv = goo_canvas_image_get_private (object);
+
switch (prop_id)
{
case PROP_PATTERN:
@@ -243,6 +285,9 @@ goo_canvas_image_get_common_property (GObject *object,
case PROP_HEIGHT:
g_value_set_double (value, image_data->height);
break;
+ case PROP_SCALE_TO_FIT:
+ g_value_set_boolean (value, priv->scale_to_fit);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -271,6 +316,7 @@ goo_canvas_image_set_common_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
+ GooCanvasImagePrivate *priv = goo_canvas_image_get_private (object);
GdkPixbuf *pixbuf;
switch (prop_id)
@@ -292,6 +338,9 @@ goo_canvas_image_set_common_property (GObject *object,
case PROP_HEIGHT:
image_data->height = g_value_get_double (value);
break;
+ case PROP_SCALE_TO_FIT:
+ priv->scale_to_fit = g_value_get_boolean (value);
+ break;
case PROP_PIXBUF:
cairo_pattern_destroy (image_data->pattern);
pixbuf = g_value_get_object (value);
@@ -365,15 +414,32 @@ goo_canvas_image_paint (GooCanvasItemSimple *simple,
cairo_t *cr,
const GooCanvasBounds *bounds)
{
+ GooCanvasImagePrivate *priv = goo_canvas_image_get_private (simple);
GooCanvasImage *image = (GooCanvasImage*) simple;
GooCanvasImageData *image_data = image->image_data;
- cairo_matrix_t matrix;
+ cairo_matrix_t matrix = { 1, 0, 0, 1, 0, 0 };
+ cairo_surface_t *surface;
+ gdouble width, height;
if (!image_data->pattern)
return;
#if 1
- cairo_matrix_init_translate (&matrix, -image_data->x, -image_data->y);
+ if (priv->scale_to_fit)
+ {
+ if (cairo_pattern_get_surface (image_data->pattern, &surface)
+ == CAIRO_STATUS_SUCCESS
+ && cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE)
+ {
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ cairo_matrix_scale (&matrix, width / image_data->width,
+ height / image_data->height);
+ }
+ }
+
+ cairo_matrix_translate (&matrix, -image_data->x, -image_data->y);
+
cairo_pattern_set_matrix (image_data->pattern, &matrix);
goo_canvas_style_set_fill_options (simple->simple_data->style, cr);
cairo_set_source (cr, image_data->pattern);
@@ -428,6 +494,8 @@ goo_canvas_image_class_init (GooCanvasImageClass *klass)
GObjectClass *gobject_class = (GObjectClass*) klass;
GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
+ g_type_class_add_private (gobject_class, sizeof (GooCanvasImagePrivate));
+
gobject_class->dispose = goo_canvas_image_dispose;
gobject_class->finalize = goo_canvas_image_finalize;
@@ -489,6 +557,8 @@ goo_canvas_image_model_class_init (GooCanvasImageModelClass *klass)
{
GObjectClass *gobject_class = (GObjectClass*) klass;
+ g_type_class_add_private (gobject_class, sizeof (GooCanvasImagePrivate));
+
gobject_class->dispose = goo_canvas_image_model_dispose;
gobject_class->get_property = goo_canvas_image_model_get_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]