Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, get the <code>GtkTextBuffer</code> from the <code>GtkTextView</code> using <code>gtk_text_view_get_buffer()</code>. Then get the start and end <em>GtkTextIters</em> from the buffer to use to get the text of the buffer. Finally, write that text to the file using the API of your choice, however, I would recommend <code>Gio</code>. Here's a snippet from my old tutorial:</p> <pre class="lang-c prettyprint-override"><code>gtk_widget_set_sensitive (text_view, FALSE); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor-&gt;text_view)); gtk_text_buffer_get_start_iter (buffer, &amp;start); gtk_text_buffer_get_end_iter (buffer, &amp;end); text = gtk_text_buffer_get_text (buffer, &amp;start, &amp;end, FALSE); gtk_text_buffer_set_modified (buffer, FALSE); gtk_widget_set_sensitive (editor-&gt;text_view, TRUE); /* set the contents of the file to the text from the buffer */ if (filename != NULL) result = g_file_set_contents (filename, text, -1, &amp;err); else result = g_file_set_contents (editor-&gt;filename, text, -1, &amp;err); if (result == FALSE) { /* error saving file, show message to user */ error_message (err-&gt;message); g_error_free (err); } g_free (text); </code></pre> <p>Check out the following API documentation:</p> <ol> <li><a href="http://developer.gnome.org/gtk3/stable/GtkTextBuffer.html" rel="nofollow">http://developer.gnome.org/gtk3/stable/GtkTextBuffer.html</a></li> <li><a href="http://developer.gnome.org/gtk3/stable/GtkTextBuffer.html" rel="nofollow">http://developer.gnome.org/glib/stable/glib-File-Utilities.html</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload