/usr/share/gtk-doc/html/goocanvas/goocanvas-model-view-canvas.html is in libgoocanvas-dev 0.15-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Model/View Canvas Example</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GooCanvas Reference Manual">
<link rel="up" href="ch01.html" title="Introduction">
<link rel="prev" href="goocanvas-simple-canvas.html" title="Simple Canvas Example">
<link rel="next" href="goocanvas-architecture.html" title="Underlying Architecture">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="ch01.html" title="Introduction">
<link rel="chapter" href="ch02.html" title="Core Objects">
<link rel="chapter" href="ch03.html" title="Standard Canvas Items">
<link rel="chapter" href="ch04.html" title="Standard Canvas Item Models">
<link rel="chapter" href="ch05.html" title="Miscellaneous">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="goocanvas-simple-canvas.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GooCanvas Reference Manual</th>
<td><a accesskey="n" href="goocanvas-architecture.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry" lang="en">
<a name="goocanvas-model-view-canvas"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Model/View Canvas Example</span></h2>
<p>Model/View Canvas Example — how to create a model/view canvas.</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1" lang="en">
<a name="model-view-overview"></a><h2>Model View Canvas Example</h2>
<p>
Here's a complete example application that creates a model-view <a class="link" href="GooCanvas.html" title="GooCanvas"><span class="type">GooCanvas</span></a>
with a rectangle and a text item in it.
</p>
<div class="informalexample"><pre class="programlisting">
#include <stdlib.h>
#include <goocanvas.h>
static gboolean on_rect_button_press (GooCanvasItem *view,
GooCanvasItem *target,
GdkEventButton *event,
gpointer data);
static gboolean on_delete_event (GtkWidget *window,
GdkEvent *event,
gpointer unused_data);
int
main (int argc, char *argv[])
{
GtkWidget *window, *scrolled_win, *canvas;
GooCanvasItemModel *root, *rect_model, *text_model;
GooCanvasItem *rect_item;
/* Initialize GTK+. */
gtk_set_locale ();
gtk_init (&argc, &argv);
/* Create the window and widgets. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 600);
gtk_widget_show (window);
g_signal_connect (window, "delete_event", (GtkSignalFunc) on_delete_event,
NULL);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
GTK_SHADOW_IN);
gtk_widget_show (scrolled_win);
gtk_container_add (GTK_CONTAINER (window), scrolled_win);
canvas = goo_canvas_new ();
gtk_widget_set_size_request (canvas, 600, 450);
goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
gtk_widget_show (canvas);
gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);
root = goo_canvas_group_model_new (NULL, NULL);
/* Add a few simple items. */
rect_model = goo_canvas_rect_model_new (root, 100, 100, 400, 400,
"line-width", 10.0,
"radius-x", 20.0,
"radius-y", 10.0,
"stroke-color", "yellow",
"fill-color", "red",
NULL);
text_model = goo_canvas_text_model_new (root, "Hello World", 300, 300, -1,
GTK_ANCHOR_CENTER,
"font", "Sans 24",
NULL);
goo_canvas_item_model_rotate (text_model, 45, 300, 300);
goo_canvas_set_root_item_model (GOO_CANVAS (canvas), root);
/* Connect a signal handler for the rectangle item. */
rect_item = goo_canvas_get_item (GOO_CANVAS (canvas), rect_model);
g_signal_connect (rect_item, "button_press_event",
(GtkSignalFunc) on_rect_button_press, NULL);
/* Pass control to the GTK+ main event loop. */
gtk_main ();
return 0;
}
/* This handles button presses in item views. We simply output a message to
the console. */
static gboolean
on_rect_button_press (GooCanvasItem *item,
GooCanvasItem *target,
GdkEventButton *event,
gpointer data)
{
g_print ("rect item received button press event\n");
return TRUE;
}
/* This is our handler for the "delete-event" signal of the window, which
is emitted when the 'x' close button is clicked. We just exit here. */
static gboolean
on_delete_event (GtkWidget *window,
GdkEvent *event,
gpointer unused_data)
{
exit (0);
}
</pre></div>
</div>
</div>
</body>
</html>
|