mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2025-01-12 20:03:28 +01:00
Make gfm directory for GFM files.
This commit is contained in:
parent
2c794f908b
commit
f0bb799250
20 changed files with 96 additions and 96 deletions
36
Rakefile
36
Rakefile
|
@ -10,11 +10,11 @@ end
|
|||
srcfiles = Sec_files.new srcfiles
|
||||
srcfiles.renum!
|
||||
|
||||
mdfilenames = srcfiles.map {|srcfile| srcfile.to_md}
|
||||
htmlfilenames = srcfiles.map {|srcfile| "html/"+srcfile.to_html}
|
||||
texfilenames = srcfiles.map {|srcfile| "latex/"+srcfile.to_tex}
|
||||
mdfilenames = srcfiles.map {|srcfile| "gfm/#{srcfile.to_md}"}
|
||||
htmlfilenames = srcfiles.map {|srcfile| "html/#{srcfile.to_html}"}
|
||||
texfilenames = srcfiles.map {|srcfile| "latex/#{srcfile.to_tex}"}
|
||||
|
||||
["html", "latex"].each do |d|
|
||||
["gfm", "html", "latex"].each do |d|
|
||||
if ! Dir.exist?(d)
|
||||
Dir.mkdir(d)
|
||||
end
|
||||
|
@ -127,7 +127,7 @@ EOS
|
|||
task default: :md
|
||||
task all: [:md, :html, :pdf]
|
||||
|
||||
task md: mdfilenames+["Readme.md"]
|
||||
task md: ["Readme.md"]
|
||||
|
||||
file "Readme.md" => mdfilenames do
|
||||
buf = [ "# Gtk4 Tutorial for beginners\n", "\n" ]
|
||||
|
@ -136,27 +136,27 @@ file "Readme.md" => mdfilenames do
|
|||
0.upto(srcfiles.size-1) do |i|
|
||||
h = File.open(srcfiles[i].path) { |file| file.readline }
|
||||
h = h.gsub(/^#* */,"").chomp
|
||||
buf << "- [#{h}](#{srcfiles[i].to_md})\n"
|
||||
buf << "- [#{h}](gfm/#{srcfiles[i].to_md})\n"
|
||||
end
|
||||
File.write("Readme.md", buf.join)
|
||||
end
|
||||
|
||||
0.upto(srcfiles.size - 1) do |i|
|
||||
file srcfiles[i].to_md => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, srcfiles[i].to_md, -1
|
||||
file "gfm/#{srcfiles[i].to_md}" => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, "gfm/#{srcfiles[i].to_md}", -1
|
||||
if srcfiles.size == 1
|
||||
nav = "Up: [Readme.md](Readme.md)\n"
|
||||
nav = "Up: [Readme.md](../Readme.md)\n"
|
||||
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
|
||||
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
|
||||
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
|
||||
buf = IO.readlines srcfiles[i].to_md
|
||||
buf = IO.readlines "gfm/#{srcfiles[i].to_md}"
|
||||
buf.insert(0, nav, "\n")
|
||||
buf.append("\n", nav)
|
||||
IO.write srcfiles[i].to_md, buf.join
|
||||
IO.write "gfm/#{srcfiles[i].to_md}", buf.join
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,8 +173,8 @@ file "html/index.html" do
|
|||
end
|
||||
|
||||
0.upto(srcfiles.size - 1) do |i|
|
||||
file "html/"+srcfiles[i].to_html => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, "html/"+srcfiles[i].to_md, -1
|
||||
file "html/#{srcfiles[i].to_html}" => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, "html/#{srcfiles[i].to_html}", -1
|
||||
buf = IO.readlines "html/"+srcfiles[i].to_md
|
||||
buf.each do |line|
|
||||
line.gsub!(/(\[[^\]]*\])\((sec\d+)\.md\)/,"\\1(\\2.html)")
|
||||
|
@ -220,8 +220,8 @@ file "latex/main.tex" do
|
|||
end
|
||||
|
||||
0.upto(srcfiles.size - 1) do |i|
|
||||
file "latex/"+srcfiles[i].to_tex => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, "latex/"+srcfiles[i].to_md, 80
|
||||
file "latex/#{srcfiles[i].to_tex}" => (srcfiles[i].c_files << srcfiles[i].path) do
|
||||
src2md srcfiles[i].path, "latex/#{srcfiles[i].to_tex}", 80
|
||||
sh "pandoc -o latex/#{srcfiles[i].to_tex} latex/#{srcfiles[i].to_md}"
|
||||
File.delete("latex/#{srcfiles[i].to_md}")
|
||||
end
|
||||
|
|
36
Readme.md
36
Readme.md
|
@ -11,21 +11,21 @@ If you find any bugs, errors or mistakes in the tutorial and C examples,
|
|||
please let me know.
|
||||
You can post it to [github issues](https://github.com/ToshioCP/Gtk4-tutorial/issues).
|
||||
|
||||
- [Prerequisite and Licence](sec1.md)
|
||||
- [Installation of gtk4 to linux distributions](sec2.md)
|
||||
- [GtkApplication and GtkApplicationWindow](sec3.md)
|
||||
- [Widgets (1)](sec4.md)
|
||||
- [Widgets (2)](sec5.md)
|
||||
- [Widgets (3)](sec6.md)
|
||||
- [Define Child object](sec7.md)
|
||||
- [Ui file and GtkBuiler](sec8.md)
|
||||
- [Build system](sec9.md)
|
||||
- [Instance and class](sec10.md)
|
||||
- [Signals](sec11.md)
|
||||
- [Functions in TfeTextView](sec12.md)
|
||||
- [Functions with GtkNotebook](sec13.md)
|
||||
- [tfeapplication.c](sec14.md)
|
||||
- [tfe5 source files](sec15.md)
|
||||
- [Menu and action](sec16.md)
|
||||
- [Stateful action](sec17.md)
|
||||
- [Ui file for menu and action entries](sec18.md)
|
||||
- [Prerequisite and Licence](gfm/sec1.md)
|
||||
- [Installation of gtk4 to linux distributions](gfm/sec2.md)
|
||||
- [GtkApplication and GtkApplicationWindow](gfm/sec3.md)
|
||||
- [Widgets (1)](gfm/sec4.md)
|
||||
- [Widgets (2)](gfm/sec5.md)
|
||||
- [Widgets (3)](gfm/sec6.md)
|
||||
- [Define Child object](gfm/sec7.md)
|
||||
- [Ui file and GtkBuiler](gfm/sec8.md)
|
||||
- [Build system](gfm/sec9.md)
|
||||
- [Instance and class](gfm/sec10.md)
|
||||
- [Signals](gfm/sec11.md)
|
||||
- [Functions in TfeTextView](gfm/sec12.md)
|
||||
- [Functions with GtkNotebook](gfm/sec13.md)
|
||||
- [tfeapplication.c](gfm/sec14.md)
|
||||
- [tfe5 source files](gfm/sec15.md)
|
||||
- [Menu and action](gfm/sec16.md)
|
||||
- [Stateful action](gfm/sec17.md)
|
||||
- [Ui file for menu and action entries](gfm/sec18.md)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
||||
Up: [Readme.md](Readme.md), Next: [Section 2](sec2.md)
|
||||
Up: [Readme.md](../Readme.md), Next: [Section 2](sec2.md)
|
|
@ -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
|
||||
|
||||
|
@ -88,7 +88,7 @@ This is very important.
|
|||
It guarantees a child widget to derive all the features from ancestors.
|
||||
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
|
||||
|
@ -342,7 +342,7 @@ Override is rewriting ancestors' class methods in the descendent class.)
|
|||
TfeTextViewClass includes its ancsestors' class in it.
|
||||
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
|
||||
|
||||
|
@ -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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -162,4 +162,4 @@ The following is extract from `tfetexties.c`.
|
|||
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)
|
|
@ -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
|
||||
|
||||
|
@ -233,7 +233,7 @@ The buttons are Cancel and Save.
|
|||
- 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.
|
||||
|
||||
![Saveas process](image/saveas.png)
|
||||
![Saveas process](../image/saveas.png)
|
||||
|
||||
When you use GtkFileChooserDialog, you need to divide the program into two parts.
|
||||
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.
|
||||
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`.
|
||||
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).
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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)
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -621,4 +621,4 @@ The followings are the source files of tfe5.
|
|||
64 105 2266 tfe5/tfe.ui
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
It is like this:
|
||||
|
||||
![Menu](image/menu.png)
|
||||
![Menu](../image/menu.png)
|
||||
|
||||
Now let's analyze the menu above.
|
||||
There are two types of object.
|
||||
|
@ -20,7 +20,7 @@ They are called "menu".
|
|||
Menu is an ordered list of items.
|
||||
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".
|
||||
- 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.
|
||||
- 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)
|
|
@ -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
|
||||
|
||||
|
@ -206,7 +206,7 @@ It is the string "s" given at the generation time.
|
|||
The following code includes stateful actions above.
|
||||
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.
|
||||
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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
Its name is `menu3`.
|
||||
|
||||
![menu3](image/menu3.png)
|
||||
![menu3](../image/menu3.png)
|
||||
|
||||
The following is the ui file of the menu in `menu3`.
|
||||
|
||||
|
@ -338,4 +338,4 @@ meson.build
|
|||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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 and GtkWidget](image/window_widget.png)
|
||||
![GtkWindow and GtkWidget](../image/window_widget.png)
|
||||
|
||||
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.
|
||||
|
||||
![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.
|
||||
|
||||
|
@ -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.
|
||||
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)
|
|
@ -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)
|
||||
|
||||
|
@ -49,7 +49,7 @@ Then compile and run it.
|
|||
|
||||
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`.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
|
||||
![Parent-child relationship](image/box.png)
|
||||
![Parent-child relationship](../image/box.png)
|
||||
|
||||
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.
|
||||
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 `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)
|
|
@ -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)
|
||||
|
||||
|
@ -70,7 +70,7 @@ In line 30, `tv` is set to `win` as a child.
|
|||
|
||||
Now compile and run it.
|
||||
|
||||
![GtkTextView](image/screenshot_tfv1.png)
|
||||
![GtkTextView](../image/screenshot_tfv1.png)
|
||||
|
||||
There's an I-beam pointer in the window.
|
||||
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.
|
||||
|
||||
|
||||
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)
|
|
@ -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)
|
||||
|
||||
|
@ -152,7 +152,7 @@ Then compile and run it.
|
|||
$ comp tfv3
|
||||
$ ./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`.
|
||||
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](image/screenshot_gtk_notebook.png)
|
||||
![GtkNotebook](../image/screenshot_gtk_notebook.png)
|
||||
|
||||
Look at the screenshots above.
|
||||
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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -41,7 +41,7 @@ What we are thinking about now is "child object".
|
|||
A child object includes its 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.
|
||||
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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -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.
|
||||
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 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.
|
||||
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
||||
|
@ -425,4 +425,4 @@ We divided a file into some categorized files and used a build tool.
|
|||
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)
|
Loading…
Reference in a new issue