Commit 1f061e27 authored by Jonas Danielsson's avatar Jonas Danielsson Committed by Jiří Techet

Add ChamplainExportable interface

https://bugzilla.gnome.org/show_bug.cgi?id=757350
parent 2123b604
......@@ -45,7 +45,9 @@ libchamplain_headers_public = \
$(srcdir)/champlain-adjustment.h \
$(srcdir)/champlain-kinetic-scroll-view.h \
$(srcdir)/champlain-viewport.h \
$(srcdir)/champlain-bounding-box.h
$(srcdir)/champlain-bounding-box.h \
$(srcdir)/champlain-exportable.h
libchamplain_headers_private = \
$(srcdir)/champlain-debug.h \
......@@ -91,7 +93,8 @@ libchamplain_sources = \
champlain-adjustment.c \
champlain-kinetic-scroll-view.c \
champlain-viewport.c \
champlain-bounding-box.c
champlain-bounding-box.c \
$(srcdir)/champlain-exportable.c
champlain-features.h: $(top_builddir)/config.status
$(AM_V_GEN) ( cd $(top_builddir) && ./config.status champlain/$@ )
......
/*
* Copyright (C) 2015 Jonas Danielsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
/**
* SECTION:champlain-exportable
* @short_description: An interface for objects exportable to a cairo surface
*
* By implementing #ChamplainExportable the object declares that it has a cairo
* surface (#cairo_surface_t) representation of it self.
*/
#include "champlain-exportable.h"
#include "champlain-private.h"
#include <cairo-gobject.h>
typedef ChamplainExportableIface ChamplainExportableInterface;
G_DEFINE_INTERFACE (ChamplainExportable, champlain_exportable, G_TYPE_OBJECT);
static void
champlain_exportable_default_init (ChamplainExportableInterface *iface)
{
/**
* ChamplainExportable:surface:
*
* A #cairo_surface_t representation
*
* Since: 0.12.12
*/
g_object_interface_install_property (iface,
g_param_spec_boxed ("surface",
"Surface",
"Cairo surface representaion",
CAIRO_GOBJECT_TYPE_SURFACE,
G_PARAM_READWRITE));
}
/**
* champlain_exportable_set_surface:
* @exportable: the #ChamplainExportable
* @surface: the #cairo_surface_t
*
* Set a #cairo_surface_t to be associated with this tile.
*
* Since: 0.12.12
*/
void
champlain_exportable_set_surface (ChamplainExportable *exportable,
cairo_surface_t *surface)
{
g_return_if_fail (CHAMPLAIN_EXPORTABLE (exportable));
g_return_if_fail (surface != NULL);
CHAMPLAIN_EXPORTABLE_GET_IFACE (exportable)->set_surface (exportable, surface);
}
/**
* champlain_exportable_get_surface:
* @exportable: a #ChamplainExportable
*
* Gets the surface
*
* Returns: (transfer none): the #cairo_surface_t of the object
*
* Since: 0.12.12
*/
cairo_surface_t *
champlain_exportable_get_surface (ChamplainExportable *exportable)
{
return CHAMPLAIN_EXPORTABLE_GET_IFACE (exportable)->get_surface (exportable);
}
/*
* Copyright (C) 2015 Jonas Danielsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (__CHAMPLAIN_CHAMPLAIN_H_INSIDE__) && !defined (CHAMPLAIN_COMPILATION)
#error "Only <champlain/champlain.h> can be included directly."
#endif
#ifndef __CHAMPLAIN_EXPORTABLE_H__
#define __CHAMPLAIN_EXPORTABLE_H__
#include <glib-object.h>
#include <cairo.h>
G_BEGIN_DECLS
#define CHAMPLAIN_TYPE_EXPORTABLE (champlain_exportable_get_type ())
#define CHAMPLAIN_EXPORTABLE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_EXPORTABLE, ChamplainExportable))
#define CHAMPLAIN_IS_EXPORTABLE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_EXPORTABLE))
#define CHAMPLAIN_EXPORTABLE_GET_IFACE(inst) \
(G_TYPE_INSTANCE_GET_INTERFACE ((inst), CHAMPLAIN_TYPE_EXPORTABLE, ChamplainExportableIface))
typedef struct _ChamplainExportable ChamplainExportable; /* Dummy object */
typedef struct _ChamplainExportableIface ChamplainExportableIface;
/**
* ChamplainExportable:
*
* An interface common to objects having a #cairo_surface_t representation.
*/
/**
* ChamplainExportableIface:
* @get_surface: virtual function for obtaining the cairo surface.
* @set_surface: virtual function for setting a cairo surface.
*
* An interface common to objects having a #cairo_surface_t representation.
*/
struct _ChamplainExportableIface
{
/*< private >*/
GTypeInterface g_iface;
/*< public >*/
cairo_surface_t *(*get_surface)(ChamplainExportable *exportable);
void (*set_surface)(ChamplainExportable *exportable,
cairo_surface_t *surface);
};
GType champlain_exportable_get_type (void) G_GNUC_CONST;
void champlain_exportable_set_surface (ChamplainExportable *exportable,
cairo_surface_t *surface);
cairo_surface_t * champlain_exportable_get_surface (ChamplainExportable *exportable);
G_END_DECLS
#endif /* __CHAMPLAIN_EXPORTABLE_H__ */
......@@ -158,6 +158,7 @@ champlain_view_get_zoom_on_double_click
champlain_view_get_animate_zoom
champlain_view_get_background_pattern
champlain_view_reload_tiles
champlain_view_to_surface
champlain_view_x_to_longitude
champlain_view_y_to_latitude
champlain_view_longitude_to_x
......@@ -785,3 +786,18 @@ CHAMPLAIN_TYPE_LOCATION
champlain_location_get_type
CHAMPLAIN_LOCATION_GET_IFACE
</SECTION>
<SECTION>
<FILE>champlain-exportable</FILE>
<TITLE>ChamplainExportable</TITLE>
ChamplainExportable
ChamplainExportableIface
champlain_exportable_set_surface
champlain_location_get_surface
<SUBSECTION Standard>
CHAMPLAIN_EXPORTABLE
CHAMPLAIN_IS_EXPORTABLE
CHAMPLAIN_TYPE_EXPORTABLE
champlain_exportable_get_type
CHAMPLAIN_EXPORTABLE_GET_IFACE
</SECTION>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment