PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/examples/gtk-demo/textview.e

http://github.com/tybor/Liberty
Specman e | 766 lines | 219 code | 133 blank | 414 comment | 5 complexity | 0695f9a0d20efe13da41602e3692f12b MD5 | raw file
  1indexing
  2	description: "Text Widget/Multiple Views"
  3	long_description: "[
  4							 The GtkTextView widget displays a GtkTextBuffer. One GtkTextBuffer
  5							 can be displayed by multiple GtkTextViews. This demo has two views
  6							 displaying a single buffer, and shows off the widget's text
  7							 formatting features.
  8							 ]"
  9	copyright: "[
 10					Copyright (C) 2006 Paolo Redaelli, GTK+ team
 11					
 12					This library is free software; you can redistribute it and/or
 13					modify it under the terms of the GNU Lesser General Public License
 14					as published by the Free Software Foundation; either version 2.1 of
 15					the License, or (at your option) any later version.
 16					
 17					This library is distributed in the hope that it will be useful, but
 18					WITHOUT ANY WARRANTY; without even the implied warranty of
 19					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 20					Lesser General Public License for more details.
 21
 22					You should have received a copy of the GNU Lesser General Public
 23					License along with this library; if not, write to the Free Software
 24					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 25					02110-1301 USA
 26					]"
 27
 28class TEXTVIEW
 29
 30insert
 31	GTK
 32	PANGO_CONSTANTS
 33	PANGO_SCALES
 34	PANGO_WEIGHT
 35	PANGO_STYLE
 36	
 37creation make
 38
 39feature -- Widgets
 40	buffer: GTK_TEXT_BUFFER
 41feature 
 42	make is 
 43		do 
 44			gtk.initialize_gtk
 45			create buffer.make
 46		end 
 47feature  -- Callbacks
 48	-- easter_egg_callback (GtkWidget *button, Gpointer data);
 49
 50feature -- constants
 51	gray50_width: INTEGER is 2
 52	gray50_height: INTEGER is 2
 53			-- static char gray50_bits[] = {0x02, 0x01}; ???
 54
 55feature -- tags	
 56	heading: GTK_TEXT_TAG is
 57		once
 58			create Result.with_name("heading")
 59			Result.set_weight (pango_weight_bold)
 60			Result.set_size (15 * pango_scale)
 61		end
 62
 63	italic: GTK_TEXT_TAG is
 64		once
 65			create Result.with_name("italic")
 66			Result.set_style (pango_style_italic)
 67		end
 68
 69	bold: GTK_TEXT_TAG is
 70		once
 71			create Result.with_name("bold")
 72			Result.set_weight ( pango_weight_bold )
 73		end
 74
 75	big: GTK_TEXT_TAG is
 76		once
 77			create Result.with_name("big")
 78			Result.set_size (20* 1024 -- i.e.: pango_scale ... TODO:
 79								  )
 80		end
 81
 82	xx_small: GTK_TEXT_TAG is
 83		once
 84			create Result.with_name("xx_small")
 85			Result.set_scale ( pango_scale_xx_small )
 86		end
 87
 88	x_large: GTK_TEXT_TAG is
 89		once
 90			create Result.with_name("x_large")
 91			-- "Extra-large", buffer.create_tag ("x-large", -- << [ "scale",
 92																					-- PANGO_SCALE_X_LARGE ] >> ); 
 93		end
 94
 95	monospace: GTK_TEXT_TAG is
 96		once
 97			create Result.with_name("monospace")
 98			--   gtk_text_buffer_create_tag (buffer, "monospace",
 99			-- 			      "family", "monospace", NULL);
100		end
101
102	blue_foreground: GTK_TEXT_TAG is
103		once
104			create Result.with_name("blue_foreground")
105			--   gtk_text_buffer_create_tag (buffer, "blue_foreground",
106			-- 			      "foreground", "blue", NULL);  
107		end
108
109	red_background: GTK_TEXT_TAG is
110		once
111			create Result.with_name("red_background")
112			--   gtk_text_buffer_create_tag (buffer, "red_background",
113			-- 			      "background", "red", NULL);
114		end
115
116	background_stipple: GTK_TEXT_TAG is
117		once
118			create Result.with_name("background_stipple")
119			--   stipple = gdk_bitmap_create_from_data (NULL,
120			-- 					 gray50_bits, gray50_width,
121			-- 					 gray50_height);
122  
123			--   gtk_text_buffer_create_tag (buffer, "background_stipple",
124			-- 			      "background_stipple", stipple, NULL);
125		end
126	
127	foreground_stipple: GTK_TEXT_TAG is
128		once
129			create Result.with_name("foreground_stipple")
130			--   gtk_text_buffer_create_tag (buffer, "foreground_stipple",
131			-- 			      "foreground_stipple", stipple, NULL);
132
133			--   g_object_unref (stipple);
134
135			--   gtk_text_buffer_create_tag (buffer, "big_gap_before_line",
136		end
137
138	big_gap_before_line: GTK_TEXT_TAG is
139		once
140			create Result.with_name("big_gap_before_line")
141			--   gtk_text_buffer_create_tag (buffer, "big_gap_before_line",
142			-- 			      "pixels_above_lines", 30, NULL);
143		end
144
145	big_gap_after_line: GTK_TEXT_TAG is
146		once
147			create Result.with_name("big_gap_after_line")
148			--   gtk_text_buffer_create_tag (buffer, "big_gap_after_line",
149			-- 			      "pixels_below_lines", 30, NULL);
150
151		end
152
153	double_spaced_line: GTK_TEXT_TAG is
154		once
155			create Result.with_name("double_spaced_line")
156			--   gtk_text_buffer_create_tag (buffer, "double_spaced_line",
157			-- 			      "pixels_inside_wrap", 10, NULL);
158		end
159
160	not_editable: GTK_TEXT_TAG is
161		once
162			create Result.with_name("not_editable")
163			--   gtk_text_buffer_create_tag (buffer, "not_editable",
164			-- 			      "editable", FALSE, NULL);
165		end
166
167	word_wrap: GTK_TEXT_TAG is
168		once
169			create Result.with_name("word_wrap")
170			--   gtk_text_buffer_create_tag (buffer, "word_wrap",
171			-- 			      "wrap_mode", GTK_WRAP_WORD, NULL);
172		end
173
174	char_wrap: GTK_TEXT_TAG is
175		once
176			create Result.with_name("char_wrap")
177			--   gtk_text_buffer_create_tag (buffer, "char_wrap",
178			-- 			      "wrap_mode", GTK_WRAP_CHAR, NULL);
179		end
180
181	no_wrap: GTK_TEXT_TAG is
182		once
183			create Result.with_name("no_wrap")
184			--   gtk_text_buffer_create_tag (buffer, "no_wrap",
185			-- 			      "wrap_mode", GTK_WRAP_NONE, NULL);
186		end
187
188	center: GTK_TEXT_TAG is
189		once
190			create Result.with_name("center")
191			--   gtk_text_buffer_create_tag (buffer, "center",
192			-- 			      "justification", GTK_JUSTIFY_CENTER, NULL);
193		end
194
195	right_justify: GTK_TEXT_TAG is
196		once
197			create Result.with_name("right_justify")
198			--   gtk_text_buffer_create_tag (buffer, "right_justify",
199			-- 			      "justification", GTK_JUSTIFY_RIGHT, NULL);
200		end
201
202	wide_margins: GTK_TEXT_TAG is
203		once
204			create Result.with_name("wide_margins")
205			--   gtk_text_buffer_create_tag (buffer, "wide_margins",
206			-- 			      "left_margin", 50, "right_margin", 50,
207			-- 			      NULL);
208  
209		end
210
211	strikethrough: GTK_TEXT_TAG is
212		once
213			create Result.with_name("strikethrough")
214			--   gtk_text_buffer_create_tag (buffer, "strikethrough",
215			-- 			      "strikethrough", TRUE, NULL);
216		end
217
218	underline: GTK_TEXT_TAG is
219		once
220			create Result.with_name("underline")
221			--   gtk_text_buffer_create_tag (buffer, "underline",
222			-- 			      "underline", PANGO_UNDERLINE_SINGLE, NULL);
223
224		end
225
226	double_underline: GTK_TEXT_TAG is
227		once
228			create Result.with_name("double_underline")
229			--   gtk_text_buffer_create_tag (buffer, "double_underline",
230			-- 			      "underline", PANGO_UNDERLINE_DOUBLE, NULL);		end
231		end
232			
233	superscript: GTK_TEXT_TAG is
234		once
235			create Result.with_name("superscript")
236			
237			--   gtk_text_buffer_create_tag (buffer, "superscript",
238			-- 			      "rise", 10 * PANGO_SCALE,	  /* 10 pixels */
239			-- 			      "size", 8 * PANGO_SCALE,	  /* 8 points */
240			-- 			      NULL);
241  		end
242
243	subscript: GTK_TEXT_TAG is
244		once
245			create Result.with_name("subscript")
246			--   gtk_text_buffer_create_tag (buffer, "subscript",
247			-- 			      "rise", -10 * PANGO_SCALE,   /* 10 pixels */
248			-- 			      "size", 8 * PANGO_SCALE,	   /* 8 points */
249			-- 			      NULL);
250		end
251	
252	rtl_quote: GTK_TEXT_TAG is
253		once
254			create Result.with_name("rtl_quote")
255			--   gtk_text_buffer_create_tag (buffer, "rtl_quote",
256			--   gtk_text_buffer_create_tag (buffer, "rtl_quote",
257			-- 			      "wrap_mode", GTK_WRAP_WORD,
258			-- 			      "direction", GTK_TEXT_DIR_RTL,
259			-- 			      "indent", 30,
260			-- 			      "left_margin", 20,
261			-- 			      "right_margin", 20,
262			-- 			      NULL);
263			-- }
264		end
265
266	tags: GTK_TEXT_TAG_TABLE is
267			-- A bunch of tags. Note that it's also possible to create
268			-- tags with `GTK_TEXT_TAG.make' then add them to the tag
269			-- table for the buffer, `GTK_TEXT_BUFFER.create_tag' is just
270			-- a convenience function. Also note that you don't have to
271			-- give tags a name; pass Void for the name to create an
272			-- anonymous tag.
273			
274			--In any real app, another useful optimization would be to
275			--create a GtkTextTagTable in advance, and reuse the same tag
276			--table for all the buffers with the same tag set, instead of
277			--creating new copies of the same tags for every buffer.
278		
279			-- Tags are assigned default priorities in order of addition
280			-- to the tag table.  That is, tags created later that affect
281			-- the same text property affected by an earlier tag will
282			-- override the earlier tag.  You can modify tag priorities
283			-- with gtk_text_tag_set_priority().
284		local stipple: GDK_BITMAP; 
285		do
286			create Result.make
287			Result.add (heading)
288			Result.add (italic)
289			Result.add (bold)
290			Result.add (big)
291			Result.add (xx_small)
292			Result.add (x_large)
293			Result.add (monospace)
294			Result.add (blue_foreground)
295			Result.add (red_background)
296			Result.add (background_stipple)
297			Result.add (foreground_stipple)
298			Result.add (big_gap_before_line)
299			Result.add (big_gap_after_line)
300			Result.add (double_spaced_line)
301			Result.add (not_editable)
302			Result.add (word_wrap)
303			Result.add (char_wrap)
304			Result.add (no_wrap)
305			Result.add (center)
306			Result.add (right_justify)
307			Result.add (wide_margins)
308			Result.add (strikethrough)
309			Result.add (underline)
310			Result.add (double_underline)
311			Result.add (superscript)
312			Result.add (subscript)
313			Result.add (rtl_quote)
314		end
315	
316
317	pixbuf: GDK_PIXBUF is
318		local		
319			filename: STRING
320		do
321			-- `demo_find_file' looks in the the current directory first,
322			-- so you can run gtk-demo without installing GTK, then looks
323			-- in the location where the file is installed.
324			
325			filename := "gtk-logo-rgb.gif" -- demo_find_file ("gtk-logo-rgb.gif", Void)
326			if filename /= Void then
327				create Result.from_file (filename)
328				
329				if Result /= Void then
330					-- g_printerr ("Failed to load image file gtk-logo-rgb.gif\n")
331					-- exit (1)
332				else 
333					-- scaled: GDK_PIXBUF;
334
335					-- TODO: scaled := pixbuf.scale_simple (32, 32, gdk_interp_bilinear)
336					-- pixbuf.unref 
337					-- TODO: check if the previous command is unnecessary,
338					-- since the following instruction will make former pixbuf
339					-- unreachable, disposable and collectable by the garbage
340					-- collector. Paolo 2006-07-05
341					-- pixbuf := scaled
342				end
343			end
344		end
345	
346	insert_text is
347		local
348			iter, start, end_iter: GTK_TEXT_ITER;
349			anchor: GTK_TEXT_CHILD_ANCHOR;
350		do
351			-- get start of buffer; each insertion will revalidate the
352			-- iterator to point to just after the inserted text.
353				
354			iter := buffer.iter_at_offset(0)
355				
356			buffer.insert_at (iter, "The text widget can display text with all %
357											%kinds of nifty attributes. It also supports %
358											%multiple views of the same buffer; this demo %
359											%is showing the same buffer in two places.\n\n")
360			buffer.insert_with_tags (iter, "Font styles. ", <<heading>>)
361  
362			buffer.insert_at (iter, "For example, you can have ")
363
364			buffer.insert_with_tags_by_name (iter, "italic", <<"italic">>)
365			buffer.insert_at (iter, ", ")
366			--buffer.insert_with_tags_by_name (iter, "bold", <<"bold">>)
367			--   gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
368			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
369			-- 					    "monospace (typewriter)", -1,
370			-- 					    "monospace", NULL);
371			--   gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
372			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
373			-- 					    "big", -1,
374			-- 					    "big", NULL);
375			--   gtk_text_buffer_insert (buffer, &iter, " text. ", -1);
376			--   gtk_text_buffer_insert (buffer, &iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ", -1);
377			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
378			-- 					    "xx-small", -1,
379			-- 					    "xx-small", NULL);
380			--   gtk_text_buffer_insert (buffer, &iter, " or ", -1);
381			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
382			-- 					    "x-large", -1,
383			-- 					    "x-large", NULL);
384			--   gtk_text_buffer_insert (buffer, &iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n", -1);
385  
386			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Colors. ", -1,
387			-- 					    "heading", NULL);
388  
389			--   gtk_text_buffer_insert (buffer, &iter, "Colors such as ", -1);  
390			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
391			-- 					    "a blue foreground", -1,
392			-- 					    "blue_foreground", NULL);
393			--   gtk_text_buffer_insert (buffer, &iter, " or ", -1);  
394			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
395			-- 					    "a red background", -1,
396			-- 					    "red_background", NULL);
397			--   gtk_text_buffer_insert (buffer, &iter, " or even ", -1);  
398			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
399			-- 					    "a stippled red background", -1,
400			-- 					    "red_background",
401			-- 					    "background_stipple",
402			-- 					    NULL);
403
404			--   gtk_text_buffer_insert (buffer, &iter, " or ", -1);  
405			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
406			-- 					    "a stippled blue foreground on solid red background", -1,
407			-- 					    "blue_foreground",
408			-- 					    "red_background",
409			-- 					    "foreground_stipple",
410			-- 					    NULL);
411			--   gtk_text_buffer_insert (buffer, &iter, " (select that to read it) can be used.\n\n", -1);  
412
413			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Underline, strikethrough, and rise. ", -1,
414			-- 					    "heading", NULL);
415  
416			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
417			-- 					    "Strikethrough", -1,
418			-- 					    "strikethrough", NULL);
419			--   gtk_text_buffer_insert (buffer, &iter, ", ", -1);
420			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
421			-- 					    "underline", -1,
422			-- 					    "underline", NULL);
423			--   gtk_text_buffer_insert (buffer, &iter, ", ", -1);
424			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
425			-- 					    "double underline", -1, 
426			-- 					    "double_underline", NULL);
427			--   gtk_text_buffer_insert (buffer, &iter, ", ", -1);
428			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
429			-- 					    "superscript", -1,
430			-- 					    "superscript", NULL);
431			--   gtk_text_buffer_insert (buffer, &iter, ", and ", -1);
432			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
433			-- 					    "subscript", -1,
434			-- 					    "subscript", NULL);
435			--   gtk_text_buffer_insert (buffer, &iter, " are all supported.\n\n", -1);
436
437			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Images. ", -1,
438			-- 					    "heading", NULL);
439  
440			--   gtk_text_buffer_insert (buffer, &iter, "The buffer can have images in it: ", -1);
441			--   gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
442			--   gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
443			--   gtk_text_buffer_insert_pixbuf (buffer, &iter, pixbuf);
444			--   gtk_text_buffer_insert (buffer, &iter, " for example.\n\n", -1);
445
446			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Spacing. ", -1,
447			-- 					    "heading", NULL);
448
449			--   gtk_text_buffer_insert (buffer, &iter, "You can adjust the amount of space before each line.\n", -1);
450  
451			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
452			-- 					    "This line has a whole lot of space before it.\n", -1,
453			-- 					    "big_gap_before_line", "wide_margins", NULL);
454			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
455			-- 					    "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n", -1,
456			-- 					    "big_gap_after_line", "wide_margins", NULL);
457  
458			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
459			-- 					    "You can also adjust the amount of space between wrapped lines; this line has extra space between each wrapped line in the same paragraph. To show off wrapping, some filler text: the quick brown fox jumped over the lazy dog. Blah blah blah blah blah blah blah blah blah.\n", -1,
460			-- 					    "double_spaced_line", "wide_margins", NULL);
461
462			--   gtk_text_buffer_insert (buffer, &iter, "Also note that those lines have extra-wide margins.\n\n", -1);
463
464			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Editability. ", -1,
465			-- 					    "heading", NULL);
466  
467			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
468			-- 					    "This line is 'locked down' and can't be edited by the user - just try it! You can't delete this line.\n\n", -1,
469			-- 					    "not_editable", NULL);
470
471			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Wrapping. ", -1,
472			-- 					    "heading", NULL);
473
474			--   gtk_text_buffer_insert (buffer, &iter,
475			-- 			  "This line (and most of the others in this buffer) is word-wrapped, using the proper Unicode algorithm. Word wrap should work in all scripts and languages that GTK+ supports. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1);  
476  
477			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
478			-- 					    "This line has character-based wrapping, and can wrap between any two character glyphs. Let's make this a long paragraph to demonstrate: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\n\n", -1,
479			-- 					    "char_wrap", NULL);
480  
481			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
482			-- 					    "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", -1,
483			-- 					    "no_wrap", NULL);
484
485			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Justification. ", -1,
486			-- 					    "heading", NULL);  
487  
488			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
489			-- 					    "\nThis line has center justification.\n", -1,
490			-- 					    "center", NULL);
491
492			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
493			-- 					    "This line has right justification.\n", -1,
494			-- 					    "right_justify", NULL);
495
496			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
497			-- 					    "\nThis line has big wide margins. Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.\n", -1,
498			-- 					    "wide_margins", NULL);  
499
500			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "Internationalization. ", -1,
501			-- 					    "heading", NULL);
502	
503			--   gtk_text_buffer_insert (buffer, &iter,
504			-- 			  "You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch S\303\274d) Gr\303\274\303\237 Gott\nGreek (\316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254) \316\223\316\265\316\271\316\254 \317\203\316\261\317\202\nHebrew	\327\251\327\234\327\225\327\235\nJapanese (\346\227\245\346\234\254\350\252\236)\n\nThe widget properly handles bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, grapheme boundaries, and so on using the Pango internationalization framework.\n", -1);  
505
506			--   gtk_text_buffer_insert (buffer, &iter, "Here's a word-wrapped quote in a right-to-left language:\n", -1);
507			--   gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\331\210\331\202\330\257 \330\250\330\257\330\243 \330\253\331\204\330\247\330\253 \331\205\331\206 \330\243\331\203\330\253\330\261 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \330\252\331\202\330\257\331\205\330\247 \331\201\331\212 \330\264\330\250\331\203\330\251 \330\247\331\203\330\263\331\212\331\210\331\206 \330\250\330\261\330\247\331\205\330\254\331\207\330\247 \331\203\331\205\331\206\330\270\331\205\330\247\330\252 \331\204\330\247 \330\252\330\263\330\271\331\211 \331\204\331\204\330\261\330\250\330\255\330\214 \330\253\331\205 \330\252\330\255\331\210\331\204\330\252 \331\201\331\212 \330\247\331\204\330\263\331\206\331\210\330\247\330\252 \330\247\331\204\330\256\331\205\330\263 \330\247\331\204\331\205\330\247\330\266\331\212\330\251 \330\245\331\204\331\211 \331\205\330\244\330\263\330\263\330\247\330\252 \331\205\330\247\331\204\331\212\330\251 \331\205\331\206\330\270\331\205\330\251\330\214 \331\210\330\250\330\247\330\252\330\252 \330\254\330\262\330\241\330\247 \331\205\331\206 \330\247\331\204\331\206\330\270\330\247\331\205 \330\247\331\204\331\205\330\247\331\204\331\212 \331\201\331\212 \330\250\331\204\330\257\330\247\331\206\331\207\330\247\330\214 \331\210\331\204\331\203\331\206\331\207\330\247 \330\252\330\252\330\256\330\265\330\265 \331\201\331\212 \330\256\330\257\331\205\330\251 \331\202\330\267\330\247\330\271 \330\247\331\204\331\205\330\264\330\261\331\210\330\271\330\247\330\252 \330\247\331\204\330\265\330\272\331\212\330\261\330\251. \331\210\330\243\330\255\330\257 \330\243\331\203\330\253\330\261 \331\207\330\260\331\207 \330\247\331\204\331\205\330\244\330\263\330\263\330\247\330\252 \331\206\330\254\330\247\330\255\330\247 \331\207\331\210 \302\273\330\250\330\247\331\206\331\203\331\210\330\263\331\210\331\204\302\253 \331\201\331\212 \330\250\331\210\331\204\331\212\331\201\331\212\330\247.\n\n", -1,
508			-- 						"rtl_quote", NULL);
509		
510			--   gtk_text_buffer_insert (buffer, &iter, "You can put widgets in the buffer: Here's a button: ", -1);
511			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
512			--   gtk_text_buffer_insert (buffer, &iter, " and a menu: ", -1);
513			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
514			--   gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
515			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
516			--   gtk_text_buffer_insert (buffer, &iter, " and an animation: ", -1);
517			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
518			--   gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
519			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
520			--   gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
521  
522			--   gtk_text_buffer_insert (buffer, &iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; it leaves out, for example: invisible/hidden text (doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...", -1);
523
524			--   /* Apply word_wrap tag to whole buffer */
525			--   gtk_text_buffer_get_bounds (buffer, &start, &end);
526			--   gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
527
528			--   g_object_unref (pixbuf);
529			-- }
530
531			-- static gboolean
532			-- find_anchor (GtkTextIter *iter)
533			-- {
534			--   while (gtk_text_iter_forward_char (iter))
535			--     {
536			--       if (gtk_text_iter_get_child_anchor (iter))
537			--         return TRUE;
538			--     }
539			--   return FALSE;
540			-- }
541
542			-- static void
543			-- attach_widgets (GtkTextView *text_view)
544			-- {
545			--   GtkTextIter iter;
546			--   GtkTextBuffer *buffer;
547			--   int i;
548  
549			--   buffer = gtk_text_view_get_buffer (text_view);
550
551			--   gtk_text_buffer_get_start_iter (buffer, &iter);
552
553			--   i = 0;
554			--   while (find_anchor (&iter))
555			--     {
556			--       GtkTextChildAnchor *anchor;
557			--       GtkWidget *widget;
558		
559			--       anchor = gtk_text_iter_get_child_anchor (&iter);
560
561			--       if (i == 0)
562			--         {
563			--           widget = gtk_button_new_with_label ("Click Me");
564
565			--           g_signal_connect (widget, "clicked",
566			--                             G_CALLBACK (easter_egg_callback),
567			--                             NULL);
568			--         }
569			--       else if (i == 1)
570			--         {
571			--           widget = gtk_combo_box_new_text ();
572
573			--           gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Option 1");
574			--           gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Option 2");
575			--           gtk_combo_box_append_text (GTK_COMBO_BOX (widget), "Option 3");
576			--         }
577			--       else if (i == 2)
578			--         {
579			--           widget = gtk_hscale_new (NULL);
580			--           gtk_range_set_range (GTK_RANGE (widget), 0, 100);
581			--           gtk_widget_set_size_request (widget, 70, -1);
582			--         }
583			--       else if (i == 3)
584			--         {
585			-- 	  gchar *filename = demo_find_file ("floppybuddy.gif", NULL);
586			-- 	  widget = gtk_image_new_from_file (filename);
587			-- 	  g_free (filename);
588			--         }
589			--       else if (i == 4)
590			--         {
591			--           widget = gtk_entry_new ();
592			--         }
593			--       else
594			--         {
595			--           widget = NULL; /* avoids a compiler warning */
596			--           g_assert_not_reached ();
597			--         }
598
599			--       gtk_text_view_add_child_at_anchor (text_view,
600			--                                          widget,
601			--                                          anchor);
602
603			--       gtk_widget_show_all (widget);
604
605			--       ++i;
606			--     }
607			-- }
608
609			-- GtkWidget *
610			-- do_textview (GtkWidget *do_widget)
611			-- {
612			--   static GtkWidget *window = NULL;
613
614			--   if (!window)
615			--     {
616			--       GtkWidget *vpaned;
617			--       GtkWidget *view1;
618			--       GtkWidget *view2;
619			--       GtkWidget *sw;
620			--       GtkTextBuffer *buffer;
621		
622			--       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
623			--       gtk_window_set_screen (GTK_WINDOW (window),
624			-- 			     gtk_widget_get_screen (do_widget));
625			--       gtk_window_set_default_size (GTK_WINDOW (window),
626			-- 				   450, 450);
627		
628			--       g_signal_connect (window, "destroy",
629			-- 			G_CALLBACK (gtk_widget_destroyed), &window);
630
631			--       gtk_window_set_title (GTK_WINDOW (window), "TextView");
632			--       gtk_container_set_border_width (GTK_CONTAINER (window), 0);
633
634			--       vpaned = gtk_vpaned_new ();
635			--       gtk_container_set_border_width (GTK_CONTAINER(vpaned), 5);
636			--       gtk_container_add (GTK_CONTAINER (window), vpaned);
637
638			--       /* For convenience, we just use the autocreated buffer from
639			--        * the first text view; you could also create the buffer
640			--        * by itself with gtk_text_buffer_new(), then later create
641			--        * a view widget.
642			--        */
643			--       view1 = gtk_text_view_new ();
644			--       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
645			--       view2 = gtk_text_view_new_with_buffer (buffer);
646		
647			--       sw = gtk_scrolled_window_new (NULL, NULL);
648			--       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
649			-- 				      GTK_POLICY_AUTOMATIC,
650			-- 				      GTK_POLICY_AUTOMATIC);
651			--       gtk_paned_add1 (GTK_PANED (vpaned), sw);
652
653			--       gtk_container_add (GTK_CONTAINER (sw), view1);
654
655			--       sw = gtk_scrolled_window_new (NULL, NULL);
656			--       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
657			-- 				      GTK_POLICY_AUTOMATIC,
658			-- 				      GTK_POLICY_AUTOMATIC);
659			--       gtk_paned_add2 (GTK_PANED (vpaned), sw);
660
661			--       gtk_container_add (GTK_CONTAINER (sw), view2);
662
663			--       create_tags (buffer);
664			--       insert_text (buffer);
665
666			--       attach_widgets (GTK_TEXT_VIEW (view1));
667			--       attach_widgets (GTK_TEXT_VIEW (view2));
668		
669			--       gtk_widget_show_all (vpaned);
670			--     }
671
672			--   if (!GTK_WIDGET_VISIBLE (window))
673			--     {
674			--       gtk_widget_show (window);
675			--     }
676			--   else
677			--     {
678			--       gtk_widget_destroy (window);
679			--       window = NULL;
680			--     }
681
682			--   return window;
683			-- }
684
685			-- static void
686			-- recursive_attach_view (int                 depth,
687			--                        GtkTextView        *view,
688			--                        GtkTextChildAnchor *anchor)
689			-- {
690			--   GtkWidget *child_view;
691			--   GtkWidget *event_box;
692			--   GdkColor color;
693			--   GtkWidget *align;
694  
695			--   if (depth > 4)
696			--     return;
697  
698			--   child_view = gtk_text_view_new_with_buffer (gtk_text_view_get_buffer (view));
699
700			--   /* Event box is to add a black border around each child view */
701			--   event_box = gtk_event_box_new ();
702			--   gdk_color_parse ("black", &color);
703			--   gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &color);
704
705			--   align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
706			--   gtk_container_set_border_width (GTK_CONTAINER (align), 1);
707  
708			--   gtk_container_add (GTK_CONTAINER (event_box), align);
709			--   gtk_container_add (GTK_CONTAINER (align), child_view);
710  
711			--   gtk_text_view_add_child_at_anchor (view, event_box, anchor);
712
713			--   recursive_attach_view (depth + 1, GTK_TEXT_VIEW (child_view), anchor);
714			-- }
715
716			-- static void
717			-- easter_egg_callback (GtkWidget *button,
718			--                      gpointer   data)
719			-- {
720			--   static GtkWidget *window = NULL;
721			--   GtkTextBuffer *buffer;
722			--   GtkWidget     *view;
723			--   GtkTextIter    iter;
724			--   GtkTextChildAnchor *anchor;
725			--   GtkWidget *sw;
726
727			--   if (window)
728			--     {
729			--       gtk_window_present (GTK_WINDOW (window));
730			--       return;
731			--     }
732  
733			--   buffer = gtk_text_buffer_new (NULL);
734
735			--   gtk_text_buffer_get_start_iter (buffer, &iter);
736
737			--   gtk_text_buffer_insert (buffer, &iter,
738			--                           "This buffer is shared by a set of nested text views.\n Nested view:\n", -1);
739			--   anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
740			--   gtk_text_buffer_insert (buffer, &iter,
741			--                           "\nDon't do this in real applications, please.\n", -1);
742
743			--   view = gtk_text_view_new_with_buffer (buffer);
744  
745			--   recursive_attach_view (0, GTK_TEXT_VIEW (view), anchor);
746  
747			--   g_object_unref (buffer);
748
749			--   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
750			--   sw = gtk_scrolled_window_new (NULL, NULL);
751			--   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
752			--                                   GTK_POLICY_AUTOMATIC,
753			--                                   GTK_POLICY_AUTOMATIC);
754
755			--   gtk_container_add (GTK_CONTAINER (window), sw);
756			--   gtk_container_add (GTK_CONTAINER (sw), view);
757
758			--   g_object_add_weak_pointer (G_OBJECT (window),
759			--                              (gpointer *) &window);
760
761			--   gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
762  
763			--   gtk_widget_show_all (window);
764			-- }
765		end
766end