GtkTextBuffer Constructor

GtkTextBuffer ([GtkTextTagTable tag_table = null]);

Returns a new GtkTextBuffer object. You can also get a new buffer by first instantiating a new GtkTextView and then calling get_buffer() .

Example 120. Instantiating a new buffer directly.

<?php
// Create a new window.
$window = new GtkWindow();
// Properly handle closing of the window.
$window->connect_simple('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!');

// 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();
?>

Example 121. Getting a new buffer from a view.

<?php
// Create a new window.
$window = new GtkWindow();
// Properly handle closing of the window.
$window->connect_simple('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!');

// 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();
?>

See also:get_buffer()