File: chapter-tutorial.html

package info (click to toggle)
gtkspell 2.0.16-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,836 kB
  • ctags: 181
  • sloc: sh: 10,126; ansic: 748; xml: 226; makefile: 95
file content (87 lines) | stat: -rw-r--r-- 4,360 bytes parent folder | download | duplicates (4)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GtkSpell Tutorial</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GtkSpell Manual">
<link rel="up" href="tutorial.html" title="Part I. Tutorial">
<link rel="prev" href="tutorial.html" title="Part I. Tutorial">
<link rel="next" href="tutorial-building.html" title="Building using GtkSpell">
<meta name="generator" content="GTK-Doc V1.11 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="tutorial.html" title="Part I. Tutorial">
<link rel="chapter" href="chapter-tutorial.html" title="GtkSpell Tutorial">
<link rel="part" href="reference.html" title="Part II. Function Reference">
</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="tutorial.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="tutorial.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">GtkSpell Manual</th>
<td><a accesskey="n" href="tutorial-building.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter" lang="en">
<div class="titlepage"><div><div><h2 class="title">
<a name="chapter-tutorial"></a>GtkSpell Tutorial</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="sect1"><a href="chapter-tutorial.html#tutorial-basic">Basic GtkSpell</a></span></dt>
<dd><dl><dt><span class="sect2"><a href="chapter-tutorial.html#tutorial-basic-first"></a></span></dt></dl></dd>
<dt><span class="sect1"><a href="tutorial-building.html">Building using GtkSpell</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="tutorial-building.html#tutorial-building-basic">Simple Programs</a></span></dt>
<dt><span class="sect2"><a href="tutorial-building.html#tutorial-building-autoconf">Building Using Autoconf</a></span></dt>
</dl></dd>
</dl></div>
<p>GtkSpell is pretty simple; including it in your program can
be as simple as calling <code class="function">gtkspell_new_attach</code> to
attach GtkSpell to a GtkTextView.  GtkSpell then watches modifications
to the GtkTextView and tries to highlight the misspellings.</p>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="tutorial-basic"></a>Basic GtkSpell</h2></div></div></div>
<div class="sect2" lang="en">
<div class="titlepage"></div>
<p>Ignoring error-checking, a basic GtkSpell-using program
will call <code class="function">gtkspell_new_attach</code> like this:</p>
<pre class="programlisting">
view = gtk_text_view_new();
gtkspell_new_attach(GTK_TEXT_VIEW(view), NULL, NULL);
</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>I leave the details of setting up the GtkTextView (setting the word wrap
mode, packing it into a GtkScrolledWindow) for the GTK documentation to
describe.
</p>
</div>
<p><code class="function">gtkspell_new_attach</code> returns <code class="literal">FALSE</code>
if there was an error (currently, the only error is one from the spell-checking
backend).  If a <em class="parameter"><code>GError **</code></em> was provided as the
last argument, the error message can be displayed to the user:</p>
<pre class="programlisting">
GError *err = NULL; /* this initialization is important. */

/* ... */

if (!gtkspell_new_attach(GTK_TEXT_VIEW(view), NULL, &amp;err)) {
	GtkWidget *errdlg;
	errdlg = gtk_message_dialog_new(main_application_window,
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_MESSAGE_ERROR,
			GTK_BUTTONS_CLOSE,
			"Error initializing spell checking: %s",
			err-&gt;message);
	gtk_dialog_run(GTK_DIALOG(errdlg));
	gtk_widget_destroy(errdlg);
	g_error_free(err); /* don't forget to free GErrors when you're done! */
}</pre>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.11</div>
</body>
</html>