From 425e9becfcae67207ecc0e4e56d3cc5f8e0ea2cd Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Tue, 20 Mar 2012 13:32:41 +0100 Subject: [PATCH 1/3] Remove the workaround for missing gobject-introspection bindings of Rsvg gobject introspection bindings for librsvg have been pushed to librsvg master [1] in 2.35.0, which solved [2]. We only have slight adopts to make in our usage, for example we can not pass the data property to the default constructor anymore and get_width and get_height is not available anymore for the handle, but we can use the properties instead. The sugar-toolkit-gtk3 and therefore Activities that have been ported to it do need a version of librsvg >= 2.35.0 to be able to work, which ships for example with Fedora 17. Signed-off-by: Simon Schampijer Acked-by: Daniel Drake [1] http://git.gnome.org/browse/librsvg/ [2] https://bugzilla.gnome.org/show_bug.cgi?id=663049 [3] http://developer.gnome.org/rsvg/stable/RsvgHandle.html --- src/sugar3/Makefile.am | 6 +- src/sugar3/graphics/icon.py | 9 +-- src/sugar3/rsvg-wrapper.c | 156 ------------------------------------ src/sugar3/rsvg-wrapper.h | 71 ---------------- 4 files changed, 5 insertions(+), 237 deletions(-) delete mode 100644 src/sugar3/rsvg-wrapper.c delete mode 100644 src/sugar3/rsvg-wrapper.h diff --git a/src/sugar3/Makefile.am b/src/sugar3/Makefile.am index 3aec8bf0..053052d5 100644 --- a/src/sugar3/Makefile.am +++ b/src/sugar3/Makefile.am @@ -48,8 +48,6 @@ libsugarext_la_SOURCES = \ gsm-session.h \ gsm-xsmp.c \ gsm-xsmp.h \ - rsvg-wrapper.c \ - rsvg-wrapper.h \ sugar-grid.c \ sugar-grid.h \ sugar-key-grabber.c \ @@ -133,9 +131,7 @@ SugarExt_1_0_gir_FILES = \ sugar-grid.c \ sugar-grid.h \ gdk-wrapper.c \ - gdk-wrapper.h \ - rsvg-wrapper.c \ - rsvg-wrapper.h + gdk-wrapper.h SugarExt_1_0_gir_INCLUDES = Gtk-3.0 Gdk-3.0 SugarExt_1_0_gir_PACKAGES = gtk+-3.0 gdk-3.0 diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py index a1800c7e..970446a7 100644 --- a/src/sugar3/graphics/icon.py +++ b/src/sugar3/graphics/icon.py @@ -29,14 +29,13 @@ from gi.repository import GObject from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GdkPixbuf +from gi.repository import Rsvg import cairo from sugar3.graphics import style from sugar3.graphics.xocolor import XoColor from sugar3.util import LRU -from gi.repository import SugarExt - _BADGE_SIZE = 0.45 @@ -64,7 +63,7 @@ class _SVGLoader(object): logging.error( 'Icon %s, entity %s is invalid.', file_name, entity) - return SugarExt.RsvgWrapper.new(icon) + return Rsvg.Handle.new_from_data(icon) class _IconInfo(object): @@ -260,8 +259,8 @@ class _IconBuffer(object): if is_svg: handle = self._load_svg(icon_info.file_name) - icon_width = handle.get_width() - icon_height = handle.get_height() + icon_width = handle.props.width + icon_height = handle.props.height else: pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_info.file_name) icon_width = pixbuf.get_width() diff --git a/src/sugar3/rsvg-wrapper.c b/src/sugar3/rsvg-wrapper.c deleted file mode 100644 index ec3a4cd7..00000000 --- a/src/sugar3/rsvg-wrapper.c +++ /dev/null @@ -1,156 +0,0 @@ -/* rsvg-wrapper.c - * Copyright (C) 2011 Raul Gutierrez Segales - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - - -/* Wrapper around rsvg while it gets introspection support. - * - * See: https://bugzilla.gnome.org/show_bug.cgi?id=663049 - */ - -#include "rsvg-wrapper.h" -#include -#include - - -G_DEFINE_TYPE (SugarRsvgWrapper, sugar_rsvg_wrapper, G_TYPE_OBJECT) - -#define RSVG_WRAPPER_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), SUGAR_TYPE_RSVG_WRAPPER, SugarRsvgWrapperPrivate)) - -struct _SugarRsvgWrapperPrivate -{ - RsvgHandle *handle; -}; - -static void -sugar_rsvg_wrapper_dispose (GObject *object) -{ - SugarRsvgWrapper *self = SUGAR_RSVG_WRAPPER (object); - SugarRsvgWrapperPrivate *priv = self->priv; - - if (priv->handle) - rsvg_handle_free (priv->handle); - - G_OBJECT_CLASS (sugar_rsvg_wrapper_parent_class)->dispose (object); -} - -static void -sugar_rsvg_wrapper_class_init (SugarRsvgWrapperClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (SugarRsvgWrapperPrivate)); - - object_class->dispose = sugar_rsvg_wrapper_dispose; -} - -static void -sugar_rsvg_wrapper_init (SugarRsvgWrapper *wrapper) -{ - SugarRsvgWrapperPrivate *priv; - - priv = wrapper->priv = RSVG_WRAPPER_PRIVATE (wrapper); - priv->handle = NULL; -} - - -/** - * sugar_rsvg_wrapper_new: - * @data: (transfer none) (array length=len): the image data - * @len: the length of @data - * - * Creates a new wrapper object - * - * Returns: (transfer full): new #SugarRsvgWrapper - **/ -SugarRsvgWrapper* -sugar_rsvg_wrapper_new (const guint8 *data, - gsize len) -{ - SugarRsvgWrapper* wrapper = g_object_new (SUGAR_TYPE_RSVG_WRAPPER, NULL); - SugarRsvgWrapperPrivate *priv; - GError *error; - - priv = RSVG_WRAPPER_PRIVATE (wrapper); - - /* My code never fails, hence I don't bother checking - * the error after the call - rgs - */ - priv->handle = rsvg_handle_new_from_data (data, len, &error); - - return wrapper; -} - -/** - * sugar_rsvg_wrapper_get_width: - * @wrapper: an #SugarRsvgWrapper - * - * Gets the width of the associated RsvgHandle. - * - * Returns: The width of the wrapped RsvgHandle - **/ -int sugar_rsvg_wrapper_get_width(SugarRsvgWrapper *wrapper) -{ - SugarRsvgWrapperPrivate *priv = RSVG_WRAPPER_PRIVATE (wrapper); - RsvgDimensionData dim; - - rsvg_handle_get_dimensions (priv->handle, &dim); - return dim.width; -} - -/** - * sugar_rsvg_wrapper_get_height: - * @wrapper: an #SugarRsvgWrapper - * - * Gets the height of the associated RsvgHandle. - * - * Returns: The height of the wrapped RsvgHandle - **/ -int sugar_rsvg_wrapper_get_height(SugarRsvgWrapper *wrapper) -{ - SugarRsvgWrapperPrivate *priv = RSVG_WRAPPER_PRIVATE (wrapper); - RsvgDimensionData dim; - - rsvg_handle_get_dimensions (priv->handle, &dim); - return dim.height; -} - -/** - * sugar_rsvg_wrapper_render_cairo: - * @wrapper: an #SugarRsvgWrapper - * @cr: the cairo region - * - **/ -void sugar_rsvg_wrapper_render_cairo(SugarRsvgWrapper *wrapper, cairo_t * cr) -{ - SugarRsvgWrapperPrivate *priv = RSVG_WRAPPER_PRIVATE (wrapper); - rsvg_handle_render_cairo (priv->handle, cr); -} - -/** - * sugar_rsvg_wrapper_get_pixbuf: - * @wrapper: an #SugarRsvgWrapper - * - * Returns: (transfer full): the #GdkPixbuf - **/ -GdkPixbuf *sugar_rsvg_wrapper_get_pixbuf(SugarRsvgWrapper *wrapper) -{ - SugarRsvgWrapperPrivate *priv = RSVG_WRAPPER_PRIVATE (wrapper); - return rsvg_handle_get_pixbuf (priv->handle); -} diff --git a/src/sugar3/rsvg-wrapper.h b/src/sugar3/rsvg-wrapper.h deleted file mode 100644 index e78c5a7f..00000000 --- a/src/sugar3/rsvg-wrapper.h +++ /dev/null @@ -1,71 +0,0 @@ -/* rsvg-wrapper.h - * Copyright (C) 2011 Raul Gutierrez Segales - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -#ifndef __RSVG_WRAPPER_H__ -#define __RSVG_WRAPPER_H__ - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define SUGAR_TYPE_RSVG_WRAPPER sugar_rsvg_wrapper_get_type () - -#define SUGAR_RSVG_WRAPPER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), SUGAR_TYPE_RSVG_WRAPPER, SugarRsvgWrapper)) - -#define SUGAR_RSVG_WRAPPER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), SUGAR_TYPE_RSVG_WRAPPER, SugarRsvgWrapperClass)) - -#define SUGAR_IS_RSVG_WRAPPER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SUGAR_TYPE_RSVG_WRAPPER)) - -#define SUGAR_IS_RSVG_WRAPPER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), SUGAR_TYPE_RSVG_WRAPPER)) - -#define SUGAR_RSVG_WRAPPER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), SUGAR_TYPE_RSVG_WRAPPER, SugarRsvgWrapperClass)) - -typedef struct _SugarRsvgWrapper SugarRsvgWrapper; -typedef struct _SugarRsvgWrapperClass SugarRsvgWrapperClass; -typedef struct _SugarRsvgWrapperPrivate SugarRsvgWrapperPrivate; - -struct _SugarRsvgWrapper -{ - GObject parent; - SugarRsvgWrapperPrivate *priv; -}; - -struct _SugarRsvgWrapperClass -{ - GObjectClass parent_class; -}; - -GType sugar_rsvg_wrapper_get_type (void); - -SugarRsvgWrapper* sugar_rsvg_wrapper_new (const guint8 *data, gsize len); -int sugar_rsvg_wrapper_load(SugarRsvgWrapper *wrapper); -int sugar_rsvg_wrapper_get_width(SugarRsvgWrapper *wrapper); -int sugar_rsvg_wrapper_get_height(SugarRsvgWrapper *wrapper); -void sugar_rsvg_wrapper_render_cairo(SugarRsvgWrapper *wrapper, cairo_t * cr); -GdkPixbuf * sugar_rsvg_wrapper_get_pixbuf(SugarRsvgWrapper *wrapper); - -#endif /* __RSVG_WRAPPER_H__ */ From 3c39375d9bb59a2bb1c9ec163645d0b4939893ae Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 22 Mar 2012 17:58:07 +0100 Subject: [PATCH 2/3] Use json as included in Python SL #3142 We use json as included in Python. This will make Sugar dependent on Python 2.6 and Python 2.7 to have the highest JSON performance. Signed-off-by: Simon Schampijer --- src/sugar3/activity/activity.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sugar3/activity/activity.py b/src/sugar3/activity/activity.py index 56371a47..808cccbf 100644 --- a/src/sugar3/activity/activity.py +++ b/src/sugar3/activity/activity.py @@ -56,6 +56,7 @@ from hashlib import sha1 from functools import partial import StringIO import cairo +import json from gi.repository import GConf from gi.repository import Gtk @@ -64,7 +65,6 @@ from gi.repository import GObject import dbus import dbus.service from dbus import PROPERTIES_IFACE -import cjson from telepathy.server import DBusProperties from telepathy.interfaces import CHANNEL, \ CHANNEL_TYPE_TEXT, \ @@ -724,8 +724,8 @@ class Activity(Window, Gtk.Container): buddies_dict = self._get_buddies() if buddies_dict: - self.metadata['buddies_id'] = cjson.encode(buddies_dict.keys()) - self.metadata['buddies'] = cjson.encode(self._get_buddies()) + self.metadata['buddies_id'] = json.dumps(buddies_dict.keys()) + self.metadata['buddies'] = json.dumps(self._get_buddies()) preview = self.get_preview() if preview is not None: From 38d881da7a47a38c517f1c03bf5558012002c3a8 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Thu, 22 Mar 2012 18:53:55 +0100 Subject: [PATCH 3/3] Release 0.95.5 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bbe28c8e..07c39ace 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([sugar-toolkit-gtk3],[0.95.4],[],[sugar-toolkit-gtk3]) +AC_INIT([sugar-toolkit-gtk3],[0.95.5],[],[sugar-toolkit-gtk3]) AC_PREREQ([2.59])