mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2025-01-12 20:03:28 +01:00
232 lines
10 KiB
HTML
232 lines
10 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>
|
||
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="sec1.html">Prev: section1</a>
|
||
</li>
|
||
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="sec3.html">Next: section3</a>
|
||
</li>
|
||
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
<h1
|
||
id="preparation-gtk-4-installation-and-the-download-of-this-repository">Preparation
|
||
(GTK 4 installation and the download of this repository)</h1>
|
||
<h2 id="installing-gtk-4-into-linux-distributions">Installing GTK 4 into
|
||
Linux distributions</h2>
|
||
<p>This section describes how to install GTK 4 into Linux
|
||
distributions.</p>
|
||
<p>There are two ways to install GTK 4.</p>
|
||
<ul>
|
||
<li>Install it from the distribution packages.</li>
|
||
<li>Build it from the source files.</li>
|
||
</ul>
|
||
<h3 id="installation-from-the-distribution-packages">Installation from
|
||
the distribution packages</h3>
|
||
<p>The first way is the easiest way to install. I’ve installed GTK 4
|
||
packages (version 4.10.1) on Ubuntu 23.04.</p>
|
||
<pre><code>$ sudo apt install libgtk-4-dev</code></pre>
|
||
<p>It is important to install the development files package
|
||
(libgtk-4-dev). Otherwise, you can’t compile any GTK 4 based
|
||
programs.</p>
|
||
<p>Fedora, Debian, Arch, Gentoo and OpenSUSE also have GTK 4 packages.
|
||
Package information for Arch, Debian/Ubuntu and Fedora is described in
|
||
<a
|
||
href="https://www.gtk.org/docs/installations/linux#installing-gtk-from-packages">Installing
|
||
GTK from packages</a>. The following table shows the distributions which
|
||
support GTK 4.</p>
|
||
<table>
|
||
<thead>
|
||
<tr class="header">
|
||
<th style="text-align: center;">Distribution</th>
|
||
<th style="text-align: center;">version</th>
|
||
<th style="text-align: center;">GTK 4</th>
|
||
<th style="text-align: center;">GNOME</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr class="odd">
|
||
<td style="text-align: center;">Fedora</td>
|
||
<td style="text-align: center;">38</td>
|
||
<td style="text-align: center;">4.10.3-2.fc38</td>
|
||
<td style="text-align: center;">GNOME 44</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td style="text-align: center;">Ubuntu</td>
|
||
<td style="text-align: center;">23.04</td>
|
||
<td style="text-align: center;">4.10.1</td>
|
||
<td style="text-align: center;">GNOME 44</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td style="text-align: center;">Debian</td>
|
||
<td style="text-align: center;">bookworm(testing)</td>
|
||
<td style="text-align: center;">4.8.3+ds-2</td>
|
||
<td style="text-align: center;">GNOME 43.4-1</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td style="text-align: center;">Arch</td>
|
||
<td style="text-align: center;">rolling release</td>
|
||
<td style="text-align: center;">4.10.3-1</td>
|
||
<td style="text-align: center;">GNOME 43.5-1</td>
|
||
</tr>
|
||
<tr class="odd">
|
||
<td style="text-align: center;">Gentoo</td>
|
||
<td style="text-align: center;">rolling release</td>
|
||
<td style="text-align: center;">4.10.3</td>
|
||
<td style="text-align: center;">GNOME 44.1</td>
|
||
</tr>
|
||
<tr class="even">
|
||
<td style="text-align: center;">OpenSUSE</td>
|
||
<td style="text-align: center;">Tumbleweed(rolling release)</td>
|
||
<td style="text-align: center;">4.10.3</td>
|
||
<td style="text-align: center;">GNOME 44.1</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h3 id="installation-from-the-source-file">Installation from the source
|
||
file</h3>
|
||
<p>If you want to install a developing version of GTK 4, you need to
|
||
build it from the source. See <a
|
||
href="https://docs.gtk.org/gtk4/building.html">Compiling the GTK
|
||
Libraries</a> section in the GTK 4 API reference.</p>
|
||
<h2 id="how-to-download-this-repository">How to download this
|
||
repository</h2>
|
||
<p>There are two ways: zip and git. Downloading a zip file is the
|
||
easiest way. However, if you use git, you can easily update your local
|
||
repository.</p>
|
||
<h3 id="download-a-zip-file">Download a zip file</h3>
|
||
<ul>
|
||
<li>Run your browser and open <a
|
||
href="https://github.com/ToshioCP/Gtk4-tutorial">this
|
||
repository</a>.</li>
|
||
<li>Click on the green button with <code><> Code</code>. Then a
|
||
popup menu appears. Click on <code>Download ZIP</code> menu.</li>
|
||
<li>Then the repository data is downloaded as a zip file into your
|
||
download folder.</li>
|
||
<li>Unzip the file.</li>
|
||
</ul>
|
||
<h3 id="clone-the-repository">Clone the repository</h3>
|
||
<ul>
|
||
<li>Click on the green button with the label <code><> Code</code>.
|
||
Then a popup menu appears. The first section is <code>Clone</code> with
|
||
three tabs. Click <code>HTTPS</code> tab and click on the copy icon,
|
||
which is on the right of
|
||
<code>https://github.com/ToshioCP/Gtk4-tutorial.git</code>.</li>
|
||
<li>Run your terminal and type <code>git clone</code>, Ctrl+Shift+V.
|
||
Then the line will be
|
||
<code>git clone https://github.com/ToshioCP/Gtk4-tutorial.git</code>.
|
||
Press the enter key.</li>
|
||
<li>A directory <code>Gtk4-tutorial</code> is created. It is the copy of
|
||
this repository.</li>
|
||
</ul>
|
||
<h2 id="examples-in-the-tutorial">Examples in the tutorial</h2>
|
||
<p>Examples are under the <code>src</code> directory. For example, the
|
||
first example of the tutorial is <code>pr1.c</code> and its pathname is
|
||
<code>src/misc/pr1.c</code>. So you don’t need to type the example codes
|
||
by yourself.</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>
|