[grits] Store GritsViewer references in GritsObjects
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grits] Store GritsViewer references in GritsObjects
- Date: Mon, 24 Jan 2011 05:30:25 +0000 (UTC)
commit c581ca3392a751075e1d851e8d2a8d0dddd7ac48
Author: Andy Spencer <andy753421 gmail com>
Date: Sat Jan 22 20:09:25 2011 +0000
Store GritsViewer references in GritsObjects
This makes it easier to write modules without having to store the viewer
reference all over the place.
It could also help simplify adding/removing objects from the viewer, but
that has not been implemented yet.
src/grits-viewer.c | 12 +++++++++---
src/objects/grits-object.h | 12 +++++++-----
2 files changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/src/grits-viewer.c b/src/grits-viewer.c
index 3a7827e..bb86d64 100644
--- a/src/grits-viewer.c
+++ b/src/grits-viewer.c
@@ -526,7 +526,9 @@ gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object,
GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer);
if (!klass->add)
g_warning("GritsViewer: add - Unimplemented");
- return klass->add(viewer, object, level, sort);
+ object->ref = klass->add(viewer, object, level, sort);
+ object->viewer = viewer;
+ return object;
}
/**
@@ -539,12 +541,16 @@ gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object,
*
* Returns: the #GritsObject referenced by the handle
*/
-GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer ref)
+GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer _object)
{
+ GritsObject *object = _object;
GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer);
if (!klass->remove)
g_warning("GritsViewer: remove - Unimplemented");
- return klass->remove(viewer, ref);
+ klass->remove(viewer, object->ref);
+ object->ref = NULL;
+ object->viewer = NULL;
+ return object;
}
/****************
diff --git a/src/objects/grits-object.h b/src/objects/grits-object.h
index b8a91a6..7ed49aa 100644
--- a/src/objects/grits-object.h
+++ b/src/objects/grits-object.h
@@ -33,14 +33,16 @@
typedef struct _GritsObject GritsObject;
typedef struct _GritsObjectClass GritsObjectClass;
+#include "grits-opengl.h"
struct _GritsObject {
- GObject parent_instance;
- GritsPoint center;
- gboolean hidden;
- gdouble lod;
+ GObject parent_instance;
+ GritsViewer *viewer; // The viewer the object was added to
+ gpointer ref; // Reference for objects that have been added
+ GritsPoint center; // Center of the object
+ gboolean hidden; // If true, the object will not be drawn
+ gdouble lod; // Level of detail, used to hide small objects
};
-#include "grits-opengl.h"
struct _GritsObjectClass {
GObjectClass parent_class;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]