Make gfm directory for GFM files.

This commit is contained in:
Toshio Sekiya 2021-01-13 20:59:15 +09:00
parent 2c794f908b
commit f0bb799250
20 changed files with 96 additions and 96 deletions

View file

@ -10,11 +10,11 @@ end
srcfiles = Sec_files.new srcfiles srcfiles = Sec_files.new srcfiles
srcfiles.renum! srcfiles.renum!
mdfilenames = srcfiles.map {|srcfile| srcfile.to_md} mdfilenames = srcfiles.map {|srcfile| "gfm/#{srcfile.to_md}"}
htmlfilenames = srcfiles.map {|srcfile| "html/"+srcfile.to_html} htmlfilenames = srcfiles.map {|srcfile| "html/#{srcfile.to_html}"}
texfilenames = srcfiles.map {|srcfile| "latex/"+srcfile.to_tex} texfilenames = srcfiles.map {|srcfile| "latex/#{srcfile.to_tex}"}
["html", "latex"].each do |d| ["gfm", "html", "latex"].each do |d|
if ! Dir.exist?(d) if ! Dir.exist?(d)
Dir.mkdir(d) Dir.mkdir(d)
end end
@ -127,7 +127,7 @@ EOS
task default: :md task default: :md
task all: [:md, :html, :pdf] task all: [:md, :html, :pdf]
task md: mdfilenames+["Readme.md"] task md: ["Readme.md"]
file "Readme.md" => mdfilenames do file "Readme.md" => mdfilenames do
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ] buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
@ -136,27 +136,27 @@ file "Readme.md" => mdfilenames do
0.upto(srcfiles.size-1) do |i| 0.upto(srcfiles.size-1) do |i|
h = File.open(srcfiles[i].path) { |file| file.readline } h = File.open(srcfiles[i].path) { |file| file.readline }
h = h.gsub(/^#* */,"").chomp h = h.gsub(/^#* */,"").chomp
buf << "- [#{h}](#{srcfiles[i].to_md})\n" buf << "- [#{h}](gfm/#{srcfiles[i].to_md})\n"
end end
File.write("Readme.md", buf.join) File.write("Readme.md", buf.join)
end end
0.upto(srcfiles.size - 1) do |i| 0.upto(srcfiles.size - 1) do |i|
file srcfiles[i].to_md => (srcfiles[i].c_files << srcfiles[i].path) do file "gfm/#{srcfiles[i].to_md}" => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, srcfiles[i].to_md, -1 src2md srcfiles[i].path, "gfm/#{srcfiles[i].to_md}", -1
if srcfiles.size == 1 if srcfiles.size == 1
nav = "Up: [Readme.md](Readme.md)\n" nav = "Up: [Readme.md](../Readme.md)\n"
elsif i == 0 elsif i == 0
nav = "Up: [Readme.md](Readme.md), Next: [Section 2](#{srcfiles[1].to_md})\n" nav = "Up: [Readme.md](../Readme.md), Next: [Section 2](#{srcfiles[1].to_md})\n"
elsif i == srcfiles.size - 1 elsif i == srcfiles.size - 1
nav = "Up: [Readme.md](Readme.md), Prev: [Section #{i}](#{srcfiles[i-1].to_md})\n" nav = "Up: [Readme.md](../Readme.md), Prev: [Section #{i}](#{srcfiles[i-1].to_md})\n"
else else
nav = "Up: [Readme.md](Readme.md), Prev: [Section #{i}](#{srcfiles[i-1].to_md}), Next: [Section #{i+2}](#{srcfiles[i+1].to_md})\n" nav = "Up: [Readme.md](../Readme.md), Prev: [Section #{i}](#{srcfiles[i-1].to_md}), Next: [Section #{i+2}](#{srcfiles[i+1].to_md})\n"
end end
buf = IO.readlines srcfiles[i].to_md buf = IO.readlines "gfm/#{srcfiles[i].to_md}"
buf.insert(0, nav, "\n") buf.insert(0, nav, "\n")
buf.append("\n", nav) buf.append("\n", nav)
IO.write srcfiles[i].to_md, buf.join IO.write "gfm/#{srcfiles[i].to_md}", buf.join
end end
end end
@ -173,8 +173,8 @@ file "html/index.html" do
end end
0.upto(srcfiles.size - 1) do |i| 0.upto(srcfiles.size - 1) do |i|
file "html/"+srcfiles[i].to_html => (srcfiles[i].c_files << srcfiles[i].path) do file "html/#{srcfiles[i].to_html}" => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, "html/"+srcfiles[i].to_md, -1 src2md srcfiles[i].path, "html/#{srcfiles[i].to_html}", -1
buf = IO.readlines "html/"+srcfiles[i].to_md buf = IO.readlines "html/"+srcfiles[i].to_md
buf.each do |line| buf.each do |line|
line.gsub!(/(\[[^\]]*\])\((sec\d+)\.md\)/,"\\1(\\2.html)") line.gsub!(/(\[[^\]]*\])\((sec\d+)\.md\)/,"\\1(\\2.html)")
@ -220,8 +220,8 @@ file "latex/main.tex" do
end end
0.upto(srcfiles.size - 1) do |i| 0.upto(srcfiles.size - 1) do |i|
file "latex/"+srcfiles[i].to_tex => (srcfiles[i].c_files << srcfiles[i].path) do file "latex/#{srcfiles[i].to_tex}" => (srcfiles[i].c_files << srcfiles[i].path) do
src2md srcfiles[i].path, "latex/"+srcfiles[i].to_md, 80 src2md srcfiles[i].path, "latex/#{srcfiles[i].to_tex}", 80
sh "pandoc -o latex/#{srcfiles[i].to_tex} latex/#{srcfiles[i].to_md}" sh "pandoc -o latex/#{srcfiles[i].to_tex} latex/#{srcfiles[i].to_md}"
File.delete("latex/#{srcfiles[i].to_md}") File.delete("latex/#{srcfiles[i].to_md}")
end end

View file

@ -11,21 +11,21 @@ If you find any bugs, errors or mistakes in the tutorial and C examples,
please let me know. please let me know.
You can post it to [github issues](https://github.com/ToshioCP/Gtk4-tutorial/issues). You can post it to [github issues](https://github.com/ToshioCP/Gtk4-tutorial/issues).
- [Prerequisite and Licence](sec1.md) - [Prerequisite and Licence](gfm/sec1.md)
- [Installation of gtk4 to linux distributions](sec2.md) - [Installation of gtk4 to linux distributions](gfm/sec2.md)
- [GtkApplication and GtkApplicationWindow](sec3.md) - [GtkApplication and GtkApplicationWindow](gfm/sec3.md)
- [Widgets (1)](sec4.md) - [Widgets (1)](gfm/sec4.md)
- [Widgets (2)](sec5.md) - [Widgets (2)](gfm/sec5.md)
- [Widgets (3)](sec6.md) - [Widgets (3)](gfm/sec6.md)
- [Define Child object](sec7.md) - [Define Child object](gfm/sec7.md)
- [Ui file and GtkBuiler](sec8.md) - [Ui file and GtkBuiler](gfm/sec8.md)
- [Build system](sec9.md) - [Build system](gfm/sec9.md)
- [Instance and class](sec10.md) - [Instance and class](gfm/sec10.md)
- [Signals](sec11.md) - [Signals](gfm/sec11.md)
- [Functions in TfeTextView](sec12.md) - [Functions in TfeTextView](gfm/sec12.md)
- [Functions with GtkNotebook](sec13.md) - [Functions with GtkNotebook](gfm/sec13.md)
- [tfeapplication.c](sec14.md) - [tfeapplication.c](gfm/sec14.md)
- [tfe5 source files](sec15.md) - [tfe5 source files](gfm/sec15.md)
- [Menu and action](sec16.md) - [Menu and action](gfm/sec16.md)
- [Stateful action](sec17.md) - [Stateful action](gfm/sec17.md)
- [Ui file for menu and action entries](sec18.md) - [Ui file for menu and action entries](gfm/sec18.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Next: [Section 2](sec2.md) Up: [Readme.md](../Readme.md), Next: [Section 2](sec2.md)
# Prerequisite and Licence # Prerequisite and Licence
@ -59,4 +59,4 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY o
See the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html) for more details. See the [GNU General Public License](https://www.gnu.org/licenses/gpl-3.0.html) for more details.
Up: [Readme.md](Readme.md), Next: [Section 2](sec2.md) Up: [Readme.md](../Readme.md), Next: [Section 2](sec2.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 9](sec9.md), Next: [Section 11](sec11.md) Up: [Readme.md](../Readme.md), Prev: [Section 9](sec9.md), Next: [Section 11](sec11.md)
# Instance and class # Instance and class
@ -88,7 +88,7 @@ This is very important.
It guarantees a child widget to derive all the features from ancestors. It guarantees a child widget to derive all the features from ancestors.
The structure of `TfeTextView` is like the following diagram. The structure of `TfeTextView` is like the following diagram.
![The structure of the instance TfeTextView](image/TfeTextView.png) ![The structure of the instance TfeTextView](../image/TfeTextView.png)
## Generate TfeTextView instance ## Generate TfeTextView instance
@ -342,7 +342,7 @@ Override is rewriting ancestors' class methods in the descendent class.)
TfeTextViewClass includes its ancsestors' class in it. TfeTextViewClass includes its ancsestors' class in it.
It is illustrated in the following diagram. It is illustrated in the following diagram.
![The structure of TfeTextView Class](image/TfeTextViewClass.png) ![The structure of TfeTextView Class](../image/TfeTextViewClass.png)
## Destruction of TfeTextView ## Destruction of TfeTextView
@ -358,7 +358,7 @@ At this moment, no object refers C and the reference count of C is zero.
This means C is no longer useful. This means C is no longer useful.
Then C destructs itself and finally the memories allocated to C is freed. Then C destructs itself and finally the memories allocated to C is freed.
![Reference count of B](image/refcount.png) ![Reference count of B](../image/refcount.png)
The idea above is based on an assumption that an object refered by nothing has reference count of zero. The idea above is based on an assumption that an object refered by nothing has reference count of zero.
When the reference count drops to zero, the object starts its destruction process. When the reference count drops to zero, the object starts its destruction process.
@ -402,7 +402,7 @@ Look at the following diagram.
There are four classes -- GObjectClass (GInitiallyUnownedClass), GtkWidgetClass, GtkTextViewClass and TfeTextViewClass. There are four classes -- GObjectClass (GInitiallyUnownedClass), GtkWidgetClass, GtkTextViewClass and TfeTextViewClass.
Each class has its own dispose handler -- `dh1`, `dh2`, `dh3` and `tfe_text_view_dispose`. Each class has its own dispose handler -- `dh1`, `dh2`, `dh3` and `tfe_text_view_dispose`.
![dispose handers](image/dispose_handler.png) ![dispose handers](../image/dispose_handler.png)
Now, look at the `tfe_text_view_dispose` program above. Now, look at the `tfe_text_view_dispose` program above.
It first releases the reference to GFile object pointed by `tv->file`. It first releases the reference to GFile object pointed by `tv->file`.
@ -418,4 +418,4 @@ After that, `dh3` calls `dh2`, and `dh2` calls `dh1`.
Finally all the references are released. Finally all the references are released.
Up: [Readme.md](Readme.md), Prev: [Section 9](sec9.md), Next: [Section 11](sec11.md) Up: [Readme.md](../Readme.md), Prev: [Section 9](sec9.md), Next: [Section 11](sec11.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 10](sec10.md), Next: [Section 12](sec12.md) Up: [Readme.md](../Readme.md), Prev: [Section 10](sec10.md), Next: [Section 12](sec12.md)
# Signals # Signals
@ -162,4 +162,4 @@ The following is extract from `tfetexties.c`.
The fourth parameter is the parameter. The fourth parameter is the parameter.
Up: [Readme.md](Readme.md), Prev: [Section 10](sec10.md), Next: [Section 12](sec12.md) Up: [Readme.md](../Readme.md), Prev: [Section 10](sec10.md), Next: [Section 12](sec12.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 11](sec11.md), Next: [Section 13](sec13.md) Up: [Readme.md](../Readme.md), Prev: [Section 11](sec11.md), Next: [Section 13](sec13.md)
# Functions in TfeTextView # Functions in TfeTextView
@ -233,7 +233,7 @@ The buttons are Cancel and Save.
- 1-16: `saveas_dialog_response` signal handler. - 1-16: `saveas_dialog_response` signal handler.
- 6-14: If the response is `GTK_RESPONSE_ACCEPT`, which is set to the argument when the user has clicked on Save button, then gets a pointer to the GFile object, set it to `tv->file`, turn on the modified bit of the GtkTextBuffer, emits "change-file" signal then call `tfe_text_view_save` to save the buffer to the file. - 6-14: If the response is `GTK_RESPONSE_ACCEPT`, which is set to the argument when the user has clicked on Save button, then gets a pointer to the GFile object, set it to `tv->file`, turn on the modified bit of the GtkTextBuffer, emits "change-file" signal then call `tfe_text_view_save` to save the buffer to the file.
![Saveas process](image/saveas.png) ![Saveas process](../image/saveas.png)
When you use GtkFileChooserDialog, you need to divide the program into two parts. When you use GtkFileChooserDialog, you need to divide the program into two parts.
They are a function which generates GtkFileChooserDialog and the signal handler. They are a function which generates GtkFileChooserDialog and the signal handler.
@ -332,7 +332,7 @@ In Gtk3, `gtk_dialog_run` function is available.
It simplifies the process. It simplifies the process.
However, in Gtk4, `gtk_dialog_run`is unavailable any more. However, in Gtk4, `gtk_dialog_run`is unavailable any more.
![Caller and TfeTextView](image/open.png) ![Caller and TfeTextView](../image/open.png)
1. A caller get a pointer `tv` to TfeTextView by calling `tfe_text_view_new`. 1. A caller get a pointer `tv` to TfeTextView by calling `tfe_text_view_new`.
2. The caller connects the handler (left bottom in the diagram) and the signal "open-response". 2. The caller connects the handler (left bottom in the diagram) and the signal "open-response".
@ -360,4 +360,4 @@ Otherwise, if the caller free the GFile object, `tv->file` is no more guaranteed
All the source files are listed in [Section 15](sec15.md). All the source files are listed in [Section 15](sec15.md).
Up: [Readme.md](Readme.md), Prev: [Section 11](sec11.md), Next: [Section 13](sec13.md) Up: [Readme.md](../Readme.md), Prev: [Section 11](sec11.md), Next: [Section 13](sec13.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 12](sec12.md), Next: [Section 14](sec14.md) Up: [Readme.md](../Readme.md), Prev: [Section 12](sec12.md), Next: [Section 14](sec14.md)
# Functions with GtkNotebook # Functions with GtkNotebook
@ -218,4 +218,4 @@ Otherwise (file is NULL), assign untitled string to `filename`.
Up: [Readme.md](Readme.md), Prev: [Section 12](sec12.md), Next: [Section 14](sec14.md) Up: [Readme.md](../Readme.md), Prev: [Section 12](sec12.md), Next: [Section 14](sec14.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 13](sec13.md), Next: [Section 15](sec15.md) Up: [Readme.md](../Readme.md), Prev: [Section 13](sec13.md), Next: [Section 15](sec15.md)
# tfeapplication.c # tfeapplication.c
@ -269,4 +269,4 @@ First, get the top level window and call `gtk_window_destroy`.
In this file, just the source file names are modified. In this file, just the source file names are modified.
Up: [Readme.md](Readme.md), Prev: [Section 13](sec13.md), Next: [Section 15](sec15.md) Up: [Readme.md](../Readme.md), Prev: [Section 13](sec13.md), Next: [Section 15](sec15.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 14](sec14.md), Next: [Section 16](sec16.md) Up: [Readme.md](../Readme.md), Prev: [Section 14](sec14.md), Next: [Section 16](sec16.md)
# tfe5 source files # tfe5 source files
@ -621,4 +621,4 @@ The followings are the source files of tfe5.
64 105 2266 tfe5/tfe.ui 64 105 2266 tfe5/tfe.ui
576 1507 17864 total 576 1507 17864 total
Up: [Readme.md](Readme.md), Prev: [Section 14](sec14.md), Next: [Section 16](sec16.md) Up: [Readme.md](../Readme.md), Prev: [Section 14](sec14.md), Next: [Section 16](sec16.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 15](sec15.md), Next: [Section 17](sec17.md) Up: [Readme.md](../Readme.md), Prev: [Section 15](sec15.md), Next: [Section 17](sec17.md)
# Menu and action # Menu and action
@ -7,7 +7,7 @@ Up: [Readme.md](Readme.md), Prev: [Section 15](sec15.md), Next: [Section 17](se
Users often use menus to tell the command to the computer. Users often use menus to tell the command to the computer.
It is like this: It is like this:
![Menu](image/menu.png) ![Menu](../image/menu.png)
Now let's analyze the menu above. Now let's analyze the menu above.
There are two types of object. There are two types of object.
@ -20,7 +20,7 @@ They are called "menu".
Menu is an ordered list of items. Menu is an ordered list of items.
They are similar to arrays. They are similar to arrays.
![Menu structure](image/menu_structure.png) ![Menu structure](../image/menu_structure.png)
- Menubar is a menu which has three items, which are "File", "Edit" and "View". - Menubar is a menu which has three items, which are "File", "Edit" and "View".
- The menu item labeled "Edit" has a link to the submenu which has two items. - The menu item labeled "Edit" has a link to the submenu which has two items.
@ -210,9 +210,9 @@ The structure of the menu is shown in the diagram below.
- 30: Set GtkApplicationWindow to show the menubar. - 30: Set GtkApplicationWindow to show the menubar.
- 31: Show the window. - 31: Show the window.
![menu and action](image/menu1.png) ![menu and action](../image/menu1.png)
![Screenshot of menu1](image/menu1_screenshot.png) ![Screenshot of menu1](../image/menu1_screenshot.png)
Up: [Readme.md](Readme.md), Prev: [Section 15](sec15.md), Next: [Section 17](sec17.md) Up: [Readme.md](../Readme.md), Prev: [Section 15](sec15.md), Next: [Section 17](sec17.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 16](sec16.md), Next: [Section 18](sec18.md) Up: [Readme.md](../Readme.md), Prev: [Section 16](sec16.md), Next: [Section 18](sec18.md)
# Stateful action # Stateful action
@ -206,7 +206,7 @@ It is the string "s" given at the generation time.
The following code includes stateful actions above. The following code includes stateful actions above.
This program has menus like this: This program has menus like this:
![menu2](image/menu2.png) ![menu2](../image/menu2.png)
- Fullscreen menu toggles the size of the window between maximum and non-maximum. - Fullscreen menu toggles the size of the window between maximum and non-maximum.
If the window is maximum size, which is called full screen, then a check mark is put before "fullscreen" label. If the window is maximum size, which is called full screen, then a check mark is put before "fullscreen" label.
@ -370,4 +370,4 @@ The provider is added to GdkDisplay.
- 90: Show the window. - 90: Show the window.
Up: [Readme.md](Readme.md), Prev: [Section 16](sec16.md), Next: [Section 18](sec18.md) Up: [Readme.md](../Readme.md), Prev: [Section 16](sec16.md), Next: [Section 18](sec18.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 17](sec17.md) Up: [Readme.md](../Readme.md), Prev: [Section 17](sec17.md)
# Ui file for menu and action entries # Ui file for menu and action entries
@ -59,7 +59,7 @@ So, we usually prefer the former ui file style.
The following is a screenshot of the sample program in this section. The following is a screenshot of the sample program in this section.
Its name is `menu3`. Its name is `menu3`.
![menu3](image/menu3.png) ![menu3](../image/menu3.png)
The following is the ui file of the menu in `menu3`. The following is the ui file of the menu in `menu3`.
@ -338,4 +338,4 @@ meson.build
10 executable('menu3', sourcefiles, resources, dependencies: gtkdep) 10 executable('menu3', sourcefiles, resources, dependencies: gtkdep)
Up: [Readme.md](Readme.md), Prev: [Section 17](sec17.md) Up: [Readme.md](../Readme.md), Prev: [Section 17](sec17.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 1](sec1.md), Next: [Section 3](sec3.md) Up: [Readme.md](../Readme.md), Prev: [Section 1](sec1.md), Next: [Section 3](sec3.md)
# Installation of gtk4 to linux distributions # Installation of gtk4 to linux distributions
@ -170,4 +170,4 @@ For example, to compile `sample.c`, type the following.
To know how to compile gtk4 applications, refer to the following sections. To know how to compile gtk4 applications, refer to the following sections.
Up: [Readme.md](Readme.md), Prev: [Section 1](sec1.md), Next: [Section 3](sec3.md) Up: [Readme.md](../Readme.md), Prev: [Section 1](sec1.md), Next: [Section 3](sec3.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 2](sec2.md), Next: [Section 4](sec4.md) Up: [Readme.md](../Readme.md), Prev: [Section 2](sec2.md), Next: [Section 4](sec4.md)
# GtkApplication and GtkApplicationWindow # GtkApplication and GtkApplicationWindow
@ -202,7 +202,7 @@ And GtkWidget is a base object from which all the GUI objects derive.
GtkWindow includes GtkWidget at the top of its object. GtkWindow includes GtkWidget at the top of its object.
![GtkWindow and GtkWidget](image/window_widget.png) ![GtkWindow and GtkWidget](../image/window_widget.png)
The function `gtk_window_new` is defined as follows. The function `gtk_window_new` is defined as follows.
@ -253,7 +253,7 @@ Save the program as `pr3.c` and compile and run it.
A small window appears. A small window appears.
![Screenshot of the window](image/screenshot_pr3.png) ![Screenshot of the window](../image/screenshot_pr3.png)
Click on the close button then the window disappears and the program finishes. Click on the close button then the window disappears and the program finishes.
@ -282,6 +282,6 @@ So you don't need to call `gtk_window_set_application` any more.
The program sets the title and the default size of the window. The program sets the title and the default size of the window.
Compile it and run `a.out`, then you will see a bigger window with its title "pr4". Compile it and run `a.out`, then you will see a bigger window with its title "pr4".
![Screenshot of the window](image/screenshot_pr4.png) ![Screenshot of the window](../image/screenshot_pr4.png)
Up: [Readme.md](Readme.md), Prev: [Section 2](sec2.md), Next: [Section 4](sec4.md) Up: [Readme.md](../Readme.md), Prev: [Section 2](sec2.md), Next: [Section 4](sec4.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 3](sec3.md), Next: [Section 5](sec5.md) Up: [Readme.md](../Readme.md), Prev: [Section 3](sec3.md), Next: [Section 5](sec5.md)
# Widgets (1) # Widgets (1)
@ -49,7 +49,7 @@ Then compile and run it.
A window with a message "Hello." appears. A window with a message "Hello." appears.
![Screenshot of the label](image/screenshot_lb1.png) ![Screenshot of the label](../image/screenshot_lb1.png)
There's only a little change between `pr4.c` and `lb1.c`. There's only a little change between `pr4.c` and `lb1.c`.
Diff is a good program to know the difference between two files. Diff is a good program to know the difference between two files.
@ -146,7 +146,7 @@ The suffix cb means "call back".
Name the program `lb2.c` and save it. Name the program `lb2.c` and save it.
Now compile and run it. Now compile and run it.
![Screenshot of the label](image/screenshot_lb2.png) ![Screenshot of the label](../image/screenshot_lb2.png)
A window with the button appears. A window with the button appears.
Click the button (it is a large button, you can click everywhere inside the window), then a string "Clicked." appears on the shell terminal. Click the button (it is a large button, you can click everywhere inside the window), then a string "Clicked." appears on the shell terminal.
@ -233,7 +233,7 @@ The following procedure shows the way to add two buttons in a window.
After this, the Widgets are connected as following diagram. After this, the Widgets are connected as following diagram.
![Parent-child relationship](image/box.png) ![Parent-child relationship](../image/box.png)
Now, code it. Now, code it.
@ -309,10 +309,10 @@ The next function fills a box with children, giving them equal space.
After that, two buttons `btn1` and `btn2` are generated and the signal handlers are set. After that, two buttons `btn1` and `btn2` are generated and the signal handlers are set.
Then, these two buttons are appended to the box. Then, these two buttons are appended to the box.
![Screenshot of the box](image/screenshot_lb4.png) ![Screenshot of the box](../image/screenshot_lb4.png)
The handler corresponds to `btn1` changes its label. The handler corresponds to `btn1` changes its label.
The handler corresponds to `btn2` destroys the top-level window and the application quits. The handler corresponds to `btn2` destroys the top-level window and the application quits.
Up: [Readme.md](Readme.md), Prev: [Section 3](sec3.md), Next: [Section 5](sec5.md) Up: [Readme.md](../Readme.md), Prev: [Section 3](sec3.md), Next: [Section 5](sec5.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 4](sec4.md), Next: [Section 6](sec6.md) Up: [Readme.md](../Readme.md), Prev: [Section 4](sec4.md), Next: [Section 6](sec6.md)
# Widgets (2) # Widgets (2)
@ -70,7 +70,7 @@ In line 30, `tv` is set to `win` as a child.
Now compile and run it. Now compile and run it.
![GtkTextView](image/screenshot_tfv1.png) ![GtkTextView](../image/screenshot_tfv1.png)
There's an I-beam pointer in the window. There's an I-beam pointer in the window.
You can add or delete any characters on GtkTextview. You can add or delete any characters on GtkTextview.
@ -164,4 +164,4 @@ This time the window doesn't extend even if you type a lot of characters.
It just scrolls. It just scrolls.
Up: [Readme.md](Readme.md), Prev: [Section 4](sec4.md), Next: [Section 6](sec6.md) Up: [Readme.md](../Readme.md), Prev: [Section 4](sec4.md), Next: [Section 6](sec6.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 5](sec5.md), Next: [Section 7](sec7.md) Up: [Readme.md](../Readme.md), Prev: [Section 5](sec5.md), Next: [Section 7](sec7.md)
# Widgets (3) # Widgets (3)
@ -152,7 +152,7 @@ Then compile and run it.
$ comp tfv3 $ comp tfv3
$ ./a.out tfv3.c $ ./a.out tfv3.c
![File viewer](image/screenshot_tfv3.png) ![File viewer](../image/screenshot_tfv3.png)
Now I want to explain the program `tfv3.c`. Now I want to explain the program `tfv3.c`.
First, the function `main` changes in only two lines. First, the function `main` changes in only two lines.
@ -199,7 +199,7 @@ If it fails, it outputs an error message and destroys the window.
GtkNotebook is a container widget that contains multiple children with tabs in it. GtkNotebook is a container widget that contains multiple children with tabs in it.
![GtkNotebook](image/screenshot_gtk_notebook.png) ![GtkNotebook](../image/screenshot_gtk_notebook.png)
Look at the screenshots above. Look at the screenshots above.
The left one is a window at the startup. The left one is a window at the startup.
@ -304,4 +304,4 @@ The numbers at the left of the following items are line numbers in the source co
- 53-56: If at least one file was read, then the number of GtkNotebookPage is greater than zero. If it's true, then show the window. If it's false, then destroy the window. - 53-56: If at least one file was read, then the number of GtkNotebookPage is greater than zero. If it's true, then show the window. If it's false, then destroy the window.
Up: [Readme.md](Readme.md), Prev: [Section 5](sec5.md), Next: [Section 7](sec7.md) Up: [Readme.md](../Readme.md), Prev: [Section 5](sec5.md), Next: [Section 7](sec7.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 6](sec6.md), Next: [Section 8](sec8.md) Up: [Readme.md](../Readme.md), Prev: [Section 6](sec6.md), Next: [Section 8](sec8.md)
# Define Child object # Define Child object
@ -41,7 +41,7 @@ What we are thinking about now is "child object".
A child object includes its parent object. A child object includes its parent object.
And a child object derives everything from the parent object. And a child object derives everything from the parent object.
![Child widget of GtkTwxtView](image/child.png) ![Child widget of GtkTwxtView](../image/child.png)
We will define TfeTextView as a child object of GtkTextView. We will define TfeTextView as a child object of GtkTextView.
It has everything that GtkTextView has. It has everything that GtkTextView has.
@ -349,4 +349,4 @@ We need more features like open, save, saveas, change font and so on.
We will add them in the next section and after. We will add them in the next section and after.
Up: [Readme.md](Readme.md), Prev: [Section 6](sec6.md), Next: [Section 8](sec8.md) Up: [Readme.md](../Readme.md), Prev: [Section 6](sec6.md), Next: [Section 8](sec8.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 7](sec7.md), Next: [Section 9](sec9.md) Up: [Readme.md](../Readme.md), Prev: [Section 7](sec7.md), Next: [Section 9](sec9.md)
# Ui file and GtkBuiler # Ui file and GtkBuiler
@ -11,7 +11,7 @@ It is better to make "New", "Open", "Save" and "Close" buttons.
This section describes how to put those buttons into the window. This section describes how to put those buttons into the window.
Signals and handlers will be explained later. Signals and handlers will be explained later.
![Screenshot of the file editor](image/screenshot_tfe2.png) ![Screenshot of the file editor](../image/screenshot_tfe2.png)
The screenshot above shows the layout. The screenshot above shows the layout.
The function `on_open` in the source code `tfe2.c` is as follows. The function `on_open` in the source code `tfe2.c` is as follows.
@ -452,4 +452,4 @@ Then, compile and run it.
The window appears and it is the same as the screenshot at the beginning of this page. The window appears and it is the same as the screenshot at the beginning of this page.
Up: [Readme.md](Readme.md), Prev: [Section 7](sec7.md), Next: [Section 9](sec9.md) Up: [Readme.md](../Readme.md), Prev: [Section 7](sec7.md), Next: [Section 9](sec9.md)

View file

@ -1,4 +1,4 @@
Up: [Readme.md](Readme.md), Prev: [Section 8](sec8.md), Next: [Section 10](sec10.md) Up: [Readme.md](../Readme.md), Prev: [Section 8](sec8.md), Next: [Section 10](sec10.md)
# Build system # Build system
@ -425,4 +425,4 @@ We divided a file into some categorized files and used a build tool.
This method is used by many developers. This method is used by many developers.
Up: [Readme.md](Readme.md), Prev: [Section 8](sec8.md), Next: [Section 10](sec10.md) Up: [Readme.md](../Readme.md), Prev: [Section 8](sec8.md), Next: [Section 10](sec10.md)