2010-09-17 18:48:02 +02:00
|
|
|
/*
|
2010-09-17 19:03:03 +02:00
|
|
|
* ld-canvas.c
|
2010-09-17 18:48:02 +02:00
|
|
|
*
|
|
|
|
* This file is a part of logdiag.
|
|
|
|
* Copyright Přemysl Janouch 2010. All rights reserved.
|
|
|
|
*
|
|
|
|
* See the file LICENSE for licensing information.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2010-09-17 19:03:03 +02:00
|
|
|
#include "ld-canvas.h"
|
|
|
|
#include "ld-document.h"
|
2010-09-17 18:48:02 +02:00
|
|
|
|
2010-09-13 19:24:53 +02:00
|
|
|
/* http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28 */
|
2010-09-17 18:48:02 +02:00
|
|
|
|
|
|
|
/**
|
2010-09-17 19:03:03 +02:00
|
|
|
* SECTION:ld-canvas
|
2010-09-17 18:48:02 +02:00
|
|
|
* @short_description: A canvas.
|
2010-09-17 19:16:53 +02:00
|
|
|
* @see_also: #LdDocument
|
2010-09-17 18:48:02 +02:00
|
|
|
*
|
2010-09-17 19:16:53 +02:00
|
|
|
* #LdCanvas is used for displaying #LdDocument objects.
|
2010-09-17 18:48:02 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2010-09-17 19:16:53 +02:00
|
|
|
* LdCanvasPrivate:
|
2010-09-17 18:48:02 +02:00
|
|
|
* @document: A document object assigned to this canvas as a model.
|
|
|
|
*/
|
2010-09-17 19:16:53 +02:00
|
|
|
struct _LdCanvasPrivate
|
2010-09-17 18:48:02 +02:00
|
|
|
{
|
2010-09-17 19:16:53 +02:00
|
|
|
LdDocument *document;
|
2010-09-17 18:48:02 +02:00
|
|
|
};
|
|
|
|
|
2010-09-17 19:16:53 +02:00
|
|
|
G_DEFINE_TYPE (LdCanvas, ld_canvas, GTK_TYPE_DRAWING_AREA);
|
2010-09-17 18:48:02 +02:00
|
|
|
|
|
|
|
static void
|
2010-09-17 19:16:53 +02:00
|
|
|
ld_canvas_finalize (GObject *gobject);
|
2010-09-17 18:48:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-09-17 19:16:53 +02:00
|
|
|
ld_canvas_class_init (LdCanvasClass *klass)
|
2010-09-17 18:48:02 +02:00
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2010-09-17 19:16:53 +02:00
|
|
|
object_class->finalize = ld_canvas_finalize;
|
2010-09-17 18:48:02 +02:00
|
|
|
|
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
/**
|
2010-09-17 19:16:53 +02:00
|
|
|
* LdCanvas::set-scroll-adjustments:
|
2010-09-17 18:48:02 +02:00
|
|
|
* @canvas: The canvas object.
|
|
|
|
*
|
|
|
|
* Contents of the library have changed.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
widget_class->set_scroll_adjustments_signal = g_signal_new
|
|
|
|
("set-scroll-adjustments", G_TYPE_FROM_CLASS (widget_class),
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
2010-09-17 19:16:53 +02:00
|
|
|
0, // G_STRUCT_OFFSET (LdCanvasClass, ...)
|
2010-09-17 18:48:02 +02:00
|
|
|
NULL, NULL,
|
|
|
|
gtk_marshal_NONE__POINTER_POINTER,
|
|
|
|
G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
|
|
|
|
*/
|
2010-09-17 19:16:53 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (LdCanvasPrivate));
|
2010-09-17 18:48:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-17 19:16:53 +02:00
|
|
|
ld_canvas_init (LdCanvas *self)
|
2010-09-17 18:48:02 +02:00
|
|
|
{
|
|
|
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
|
2010-09-17 19:16:53 +02:00
|
|
|
(self, LD_TYPE_CANVAS, LdCanvasPrivate);
|
2010-09-17 18:48:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-17 19:16:53 +02:00
|
|
|
ld_canvas_finalize (GObject *gobject)
|
2010-09-17 18:48:02 +02:00
|
|
|
{
|
2010-09-17 19:16:53 +02:00
|
|
|
LdCanvas *self;
|
2010-09-17 18:48:02 +02:00
|
|
|
|
2010-09-17 19:16:53 +02:00
|
|
|
self = LD_CANVAS (gobject);
|
2010-09-17 18:48:02 +02:00
|
|
|
|
|
|
|
/* Chain up to the parent class. */
|
2010-09-17 19:16:53 +02:00
|
|
|
G_OBJECT_CLASS (ld_canvas_parent_class)->finalize (gobject);
|
2010-09-17 18:48:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-09-17 19:16:53 +02:00
|
|
|
* ld_canvas_new:
|
2010-09-17 18:48:02 +02:00
|
|
|
*
|
|
|
|
* Create an instance.
|
|
|
|
*/
|
2010-09-17 19:16:53 +02:00
|
|
|
LdCanvas *
|
|
|
|
ld_canvas_new (void)
|
2010-09-17 18:48:02 +02:00
|
|
|
{
|
2010-09-17 19:16:53 +02:00
|
|
|
return g_object_new (LD_TYPE_CANVAS, NULL);
|
2010-09-17 18:48:02 +02:00
|
|
|
}
|