Re: cvs: php-gtk-doc /manual/en/reference/gtk gtktextbuffer.xml

From: Date: Sat, 07 May 2005 21:04:30 +0000
Subject: Re: cvs: php-gtk-doc /manual/en/reference/gtk gtktextbuffer.xml
References: 1  Groups: php.gtk.doc 
Request: Send a blank email to php-gtk-doc+get-1431@lists.php.net to get a copy of this message
Scott, Are you writing these docs from scratch? It would probably help to borrow some stuff from gtk.org and pygtk.org. -Andrei On May 5, 2005, at 5:48 AM, Scott Mattocks wrote:
scottmattocks Thu May 5 08:48:57 2005 EDT Modified files:
    /php-gtk-doc/manual/en/reference/gtk	gtktextbuffer.xml
Log: First run at some GtkTextBuffer docs. http://cvs.php.net/diff.php/php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml?r1=1.4&r2=1.5&ty=u Index: php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml diff -u php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml:1.4 php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml:1.5 --- php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml:1.4 Thu Apr 28 14:10:27 2005 +++ php-gtk-doc/manual/en/reference/gtk/gtktextbuffer.xml Thu May 5 08:48:56 2005 @@ -3,10 +3,70 @@ <classtitle>GtkTextBuffer</classtitle> <classparent>GObject</classparent> <shortdesc> - + A widget for storing and editing text. </shortdesc> <desc> - + <simpara>
+    A <classname>GtkTextBuffer</classname> stores text, which can be edited. The
+    text can then be displayed in one or more <classname>GtkTextView</classname>
+    widgets. Text in a buffer can be marked with
+    <classname>GtkTextTag</classname> widgets which apply attributes to a range
+    of text.
+ </simpara> + <simpara>
+    Text in PHP-GTK 2 is UTF-8. This means that one character can be encoded
+    as multiple bytes. Character counts are usually referred to as offsets,
+    while byte counts are called indexes. If you confuse these two, things
+    will work fine with ASCII, but as soon as your buffer contains multibyte
+    characters, bad things will happen.
+ </simpara> + <simpara>
+    A combination of <classname>GtkTextBuffer</classname> and
+    <classname>GtkTextView</classname> widgets should be used as instead of the
+    deprecated <classname>GtkText</classname> widget.
+ </simpara> + <para>
+    <example>
+     <title>Simple use of GtkTextBuffer.</title>
+     <programlisting role="php">
+<![CDATA[ +<?php +// Make sure the PHP-GTK 2 extension is loaded. +if (!extension_loaded('php-gtk')) {
+        dl( 'php_gtk2.' . PHP_SHLIB_SUFFIX);
+} + +// Create a new window. +$window = new GtkWindow(); +// Properly handle closing of the window. +$window->connect_object('destroy', array('gtk', 'main_quit')); + +// Create a new buffer and a new view to show the buffer. +$textBuffer = new GtkTextBuffer(); +$textView = new GtkTextView(); + +// Add some text to the buffer. +$textBuffer->set_text('Hello World!', -1); + +// Add the buffer to the view and make sure no one edits the text. +$textView->set_buffer($textBuffer); +$textView->set_editable(false); + +// Add the view to the window, show everything, and start the main loop. +$window->add($textView); +$window->show_all(); +Gtk::main(); +?> +]]>
+     </programlisting>
+    </example>
+ </para> + <simpara>
+    See also: <classname>GtkTextView</classname>,
+    <classname>GtkTextTag</classname>, <classname>GtkTextTagTable</classname>,
+    <classname>GtkTextIter</classname>, <classname>GtkTextMark</classname>,
+    <classname>GtkTextChildAnchor</classname>
+ </simpara> </desc> </classmeta> @@ -20,10 +80,89 @@
     </funcprototype>
    </funcsynopsis>
    <shortdesc>
-
+    Returns a new <classname>GtkTextBuffer</classname> object.
    </shortdesc>
    <desc>
-
+    <simpara>
+     Returns a new <classname>GtkTextBuffer</classname> object. You can also
+     get a new buffer by first instantiating a new
+     <classname>GtkTextView</classname> and then
+     calling <function class="GtkTextView">get_buffer</function>.
+    </simpara>
+    <para>
+     <example>
+      <title>Instantiating a new buffer directly.</title>
+      <programlisting role="php">
+<![CDATA[ +<?php +// Make sure the PHP-GTK 2 extension is loaded. +if (!extension_loaded('php-gtk')) {
+        dl( 'php_gtk2.' . PHP_SHLIB_SUFFIX);
+} + +// Create a new window. +$window = new GtkWindow(); +// Properly handle closing of the window. +$window->connect_object('destroy', array('gtk', 'main_quit')); + +// Create a new buffer and a new view to show the buffer. +$textBuffer = new GtkTextBuffer(); +$textView = new GtkTextView(); + +// Add some text to the buffer. +$textBuffer->set_text('Hello World!', -1); + +// Add the buffer to the view and make sure no one edits the text. +$textView->set_buffer($textBuffer); +$textView->set_editable(false); + +// Add the view to the window, show everything, and start the main loop. +$window->add($textView); +$window->show_all(); +Gtk::main(); +?> +]]>
+      </programlisting>
+     </example>
+     <example>
+      <title>Getting a new buffer from a view.</title>
+      <programlisting role="php">
+<![CDATA[ +<?php +// Make sure the PHP-GTK 2 extension is loaded. +if (!extension_loaded('php-gtk')) {
+        dl( 'php_gtk2.' . PHP_SHLIB_SUFFIX);
+} + +// Create a new window. +$window = new GtkWindow(); +// Properly handle closing of the window. +$window->connect_object('destroy', array('gtk', 'main_quit')); + +// Create a new view. +$textView = new GtkTextView(); + +// Get the buffer from the view. +$textBuffer = $textView->get_buffer(); + +// Add some text to the buffer. +$textBuffer->set_text('Hello World!', -1); + +// Make sure no one edits the text. +$textView->set_editable(false); + +// Add the view to the window, show everything, and start the main loop. +$window->add($textView); +$window->show_all(); +Gtk::main(); +?> +]]>
+      </programlisting>
+     </example>
+    </para>
+    <simpara>
+     See also: <function class="GtkTextView">get_buffer</function>
+    </simpara>
    </desc>
</constructor> @@ -356,10 +495,32 @@
     </funcprototype>
    </funcsynopsis>
    <shortdesc>
-
+    Returns the number of characters in the buffer.
    </shortdesc>
    <desc>
-
+    <simpara>
+     Returns the number of characters in a buffer. Remeber that because text
+     in PHP-GTK 2 is UTF-8, the number of characters may not be the same as
+     the number of bytes in the buffer.
+    </simpara>
+    <para>
+     <example>
+      <title>
+       Using <function class="GtkTextBuffer">get_char_count</function>
+      </title>
+      <programlisting role="php">
+<![CDATA[ +<?php +// Make sure the PHP-GTK 2 extension is loaded. +if (!extension_loaded('php-gtk')) {
+        dl( 'php_gtk2.' . PHP_SHLIB_SUFFIX);
+} + +// Still working on this one... +]]>
+      </programlisting>
+     </example>
+    </para>
    </desc>
</method> @@ -1230,3 +1391,22 @@ </signals> </classentry> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:"../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> --PHP-GTK Documentation Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.doc (#1431) next »