mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2024-11-16 19:50:35 +01:00
264 lines
11 KiB
HTML
264 lines
11 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="generator" content="pandoc" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
||
<title>GTK 4 tutorial</title>
|
||
<style>
|
||
code{white-space: pre-wrap;}
|
||
span.smallcaps{font-variant: small-caps;}
|
||
span.underline{text-decoration: underline;}
|
||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
|
||
ul.task-list{list-style: none;}
|
||
pre{overflow: visible;}
|
||
pre > code.sourceCode { white-space: pre; position: relative; }
|
||
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
|
||
pre > code.sourceCode > span:empty { height: 1.2em; }
|
||
code.sourceCode > span { color: inherit; text-decoration: inherit; }
|
||
div.sourceCode { margin: 1em 0; }
|
||
pre.sourceCode { margin: 0; }
|
||
@media screen {
|
||
div.sourceCode { overflow: auto; }
|
||
}
|
||
@media print {
|
||
pre > code.sourceCode { white-space: pre-wrap; }
|
||
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
|
||
}
|
||
pre.numberSource code
|
||
{ counter-reset: source-line 0; }
|
||
pre.numberSource code > span
|
||
{ position: relative; left: -4em; counter-increment: source-line; }
|
||
pre.numberSource code > span > a:first-child::after
|
||
{ content: counter(source-line);
|
||
position: relative; left: -1em; text-align: right; vertical-align: baseline;
|
||
border: none; display: inline-block;
|
||
-webkit-touch-callout: none; -webkit-user-select: none;
|
||
-khtml-user-select: none; -moz-user-select: none;
|
||
-ms-user-select: none; user-select: none;
|
||
padding: 0 4px; width: 4em;
|
||
color: #aaaaaa;
|
||
}
|
||
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
|
||
div.sourceCode
|
||
{ }
|
||
@media screen {
|
||
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
|
||
}
|
||
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
|
||
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
|
||
code span.at { color: #7d9029; } /* Attribute */
|
||
code span.bn { color: #40a070; } /* BaseN */
|
||
code span.bu { } /* BuiltIn */
|
||
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
|
||
code span.ch { color: #4070a0; } /* Char */
|
||
code span.cn { color: #880000; } /* Constant */
|
||
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
|
||
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
|
||
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
|
||
code span.dt { color: #902000; } /* DataType */
|
||
code span.dv { color: #40a070; } /* DecVal */
|
||
code span.er { color: #ff0000; font-weight: bold; } /* Error */
|
||
code span.ex { } /* Extension */
|
||
code span.fl { color: #40a070; } /* Float */
|
||
code span.fu { color: #06287e; } /* Function */
|
||
code span.im { } /* Import */
|
||
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
|
||
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
|
||
code span.op { color: #666666; } /* Operator */
|
||
code span.ot { color: #007020; } /* Other */
|
||
code span.pp { color: #bc7a00; } /* Preprocessor */
|
||
code span.sc { color: #4070a0; } /* SpecialChar */
|
||
code span.ss { color: #bb6688; } /* SpecialString */
|
||
code span.st { color: #4070a0; } /* String */
|
||
code span.va { color: #19177c; } /* Variable */
|
||
code span.vs { color: #4070a0; } /* VerbatimString */
|
||
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
|
||
div.sourceCode { margin: 10px; padding: 16px 10px 8px 10px; border: 2px solid silver; background-color: ghostwhite; overflow-x:scroll}
|
||
pre:not(.sourceCode) { margin: 10px; padding: 16px 10px 8px 10px; border: 2px solid silver; background-color: ghostwhite; overflow-x:scroll}
|
||
table {margin-left: auto; margin-right: auto; border-collapse: collapse; border: 1px solid;}
|
||
th {padding: 2px 6px; border: 1px solid; background-color: ghostwhite;}
|
||
td {padding: 2px 6px; border: 1px solid;}
|
||
img {display: block; margin-left: auto; margin-right: auto;}
|
||
figcaption {text-align: center;}
|
||
</style>
|
||
</head>
|
||
<body style="padding-top: 70px;">
|
||
<div class="container">
|
||
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-primary">
|
||
<div class="container-fluid">
|
||
<span class="navbar-brand">Gtk4 tutorial</span>
|
||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||
<span class="navbar-toggler-icon"></span>
|
||
</button>
|
||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="index.html">Home</a>
|
||
</li>
|
||
|
||
|
||
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
<h1 id="tfetextview-api-reference">TfeTextView API reference</h1>
|
||
<p>TfeTextView – Child object of GtkTextView. It is connected to a
|
||
certain file.</p>
|
||
<h2 id="functions">Functions</h2>
|
||
<ul>
|
||
<li>GFile *tfe_text_view_get_file ()</li>
|
||
<li>void tfe_text_view_open ()</li>
|
||
<li>void tfe_text_view_save ()</li>
|
||
<li>void tfe_text_view_saveas ()</li>
|
||
<li>GtkWidget *tfe_text_view_new_with_file ()</li>
|
||
<li>GtkWidget *tfe_text_view_new ()</li>
|
||
</ul>
|
||
<h2 id="signals">Signals</h2>
|
||
<ul>
|
||
<li>void change-file</li>
|
||
<li>void open-response</li>
|
||
</ul>
|
||
<h2 id="types-and-values">Types and Values</h2>
|
||
<ul>
|
||
<li>TfeTextView</li>
|
||
<li>TfeTextViewClass</li>
|
||
<li>TfeTextViewOpenResponseType</li>
|
||
</ul>
|
||
<h2 id="object-hierarchy">Object Hierarchy</h2>
|
||
<pre><code>GObject
|
||
+--GInitiallyUnowned
|
||
+--GtkWidget
|
||
+--GtkTextView
|
||
+--TfeTextView</code></pre>
|
||
<h2 id="includes">Includes</h2>
|
||
<pre><code>#include <gtk/gtk.h></code></pre>
|
||
<h2 id="description">Description</h2>
|
||
<p>TfeTextView holds GFile corresponds to the contents of GtkTextBuffer.
|
||
It has some file manipulation functions.</p>
|
||
<h2 id="functions-1">Functions</h2>
|
||
<h3 id="tfe_text_view_get_file">tfe_text_view_get_file()</h3>
|
||
<pre><code>GFile *
|
||
tfe_text_view_get_file (TfeTextView *tv);</code></pre>
|
||
<p>Returns the copy of the GFile in the TfeTextView.</p>
|
||
<p>Parameters</p>
|
||
<ul>
|
||
<li>tv: a TfeTextView</li>
|
||
</ul>
|
||
<h3 id="tfe_text_view_open">tfe_text_view_open()</h3>
|
||
<pre><code>void
|
||
tfe_text_view_open (TfeTextView *tv, GtkWidget *win);</code></pre>
|
||
<p>Just shows a GtkFileChooserDialog so that a user can choose a file to
|
||
read. This function doesn’t do any I/O operations. They are done by the
|
||
signal handler connected to the <code>response</code> signal emitted by
|
||
GtkFileChooserDialog. Therefore the caller can’t know the I/O status
|
||
directly from <code>tfe_text_view_open</code>. Instead, the status is
|
||
informed by <code>open-response</code> signal. The caller needs to set a
|
||
handler to this signal in advance.</p>
|
||
<p>parameters</p>
|
||
<ul>
|
||
<li>tv: a TfeTextView</li>
|
||
<li>win: the top level window</li>
|
||
</ul>
|
||
<h3 id="tfe_text_view_save">tfe_text_view_save()</h3>
|
||
<pre><code>void
|
||
tfe_text_view_save (TfeTextView *tv);</code></pre>
|
||
<p>Saves the contents of the TfeTextView to a file. If <code>tv</code>
|
||
holds a GFile, it is used. Otherwise, this function shows
|
||
GtkFileChooserDialog so that the user can choose a file to save.</p>
|
||
<p>Parameters</p>
|
||
<ul>
|
||
<li>tv: a TfeTextView</li>
|
||
</ul>
|
||
<h3 id="tfe_text_view_saveas">tfe_text_view_saveas()</h3>
|
||
<pre><code>void
|
||
tfe_text_view_saveas (TfeTextView *tv);</code></pre>
|
||
<p>Saves the content of a TfeTextView to a file. This function shows
|
||
GtkFileChooserDialog so that a user can choose a file to save.</p>
|
||
<p>Parameters</p>
|
||
<ul>
|
||
<li>tv: a TfeTextView</li>
|
||
</ul>
|
||
<h3 id="tfe_text_view_new_with_file">tfe_text_view_new_with_file()</h3>
|
||
<pre><code>GtkWidget *
|
||
tfe_text_view_new_with_file (GFile *file);</code></pre>
|
||
<p>Creates a new TfeTextView and reads the contents of the
|
||
<code>file</code> and set it to the GtkTextBuffer corresponds to the
|
||
newly created TfeTextView. Then returns the TfeTextView as GtkWidget. If
|
||
an error happens, it returns <code>NULL</code>.</p>
|
||
<p>Parameters</p>
|
||
<ul>
|
||
<li>file: a GFile</li>
|
||
</ul>
|
||
<p>Returns</p>
|
||
<ul>
|
||
<li>a new TfeTextView.</li>
|
||
</ul>
|
||
<h3 id="tfe_text_view_new">tfe_text_view_new()</h3>
|
||
<pre><code>GtkWidget *
|
||
tfe_text_view_new (void);</code></pre>
|
||
<p>Creates a new TfeTextView and returns the TfeTextView as GtkWidget.
|
||
If an error happens, it returns <code>NULL</code>.</p>
|
||
<p>Returns</p>
|
||
<ul>
|
||
<li>a new TfeTextView.</li>
|
||
</ul>
|
||
<h2 id="types-and-values-1">Types and Values</h2>
|
||
<h3 id="tfetextview">TfeTextView</h3>
|
||
<pre><code>typedef struct _TfeTextView TfeTextView
|
||
struct _TfeTextView
|
||
{
|
||
GtkTextView parent;
|
||
GFile *file;
|
||
};</code></pre>
|
||
<p>The members of this structure are not allowed to be accessed by any
|
||
outer objects. If you want to obtain a copy of the GFile, use
|
||
<code>tfe_text_view_get_file</code>.</p>
|
||
<h3 id="tfetextviewclass">TfeTextViewClass</h3>
|
||
<pre><code>typedef struct {
|
||
GtkTextViewClass parent_class;
|
||
} TfeTextViewClass;</code></pre>
|
||
<p>No member is added because TfeTextView is a final type object.</p>
|
||
<h3 id="enum-tfetextviewopenresponsetype">enum
|
||
TfeTextViewOpenResponseType</h3>
|
||
<p>Predefined values for the response id given by
|
||
<code>open-response</code> signal.</p>
|
||
<p>Members:</p>
|
||
<ul>
|
||
<li>TFE_OPEN_RESPONSE_SUCCESS: The file is successfully opened.</li>
|
||
<li>TFE_OPEN_RESPONSE_CANCEL: Reading file is canceled by the user.</li>
|
||
<li>TFE_OPEN_RESPONSE_ERROR: An error happened during the opening or
|
||
reading process.</li>
|
||
</ul>
|
||
<h2 id="properties">Properties</h2>
|
||
<h3 id="wrap-mode">wrap-mode</h3>
|
||
<p>The property “wrap-mode” belongs to GtkTextView. TfeTextView inherits
|
||
it and the value is set to GTK_WRAP_WORD_CHAR as a default.</p>
|
||
<h2 id="signals-1">Signals</h2>
|
||
<h3 id="change-file">change-file</h3>
|
||
<pre><code>void
|
||
user_function (TfeTextView *tv,
|
||
gpointer user_data)</code></pre>
|
||
<p>Emitted when the GFile in the TfeTextView object is changed. The
|
||
signal is emitted when:</p>
|
||
<ul>
|
||
<li>a new file is opened and read</li>
|
||
<li>a user choose a file with GtkFileChooserDialog and save the
|
||
contents.</li>
|
||
<li>an error occured during I/O operation, and GFile is removed as a
|
||
result.</li>
|
||
</ul>
|
||
<h3 id="open-response">open-response</h3>
|
||
<pre><code>void
|
||
user_function (TfeTextView *tv,
|
||
TfeTextViewOpenResponseType response-id,
|
||
gpointer user_data)</code></pre>
|
||
<p>Emitted after the user calls <code>tfe_text_view_open</code>. This
|
||
signal informs the status of file opening and reading.</p>
|
||
</div>
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
|
||
</body>
|
||
</html>
|