mirror of
https://github.com/ToshioCP/Gtk4-tutorial.git
synced 2024-11-16 19:50:35 +01:00
Modify sec 4 and 5.
This commit is contained in:
parent
2788a3712b
commit
869302fd40
16 changed files with 17 additions and 16 deletions
0
Rakefile
Executable file → Normal file
0
Rakefile
Executable file → Normal file
0
Readme_for_developers.md
Executable file → Normal file
0
Readme_for_developers.md
Executable file → Normal file
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
0
lib/lib_src2md.rb
Executable file → Normal file
0
lib/lib_src2md.rb
Executable file → Normal file
10
sec4.md
10
sec4.md
|
@ -23,7 +23,7 @@ See a sample program `tfv1.c` below.
|
|||
12 "It is a japanese word that means a man whose work is making bamboo baskets.\n"
|
||||
13 "One day, he went into a mountain and found a shining bamboo."
|
||||
14 "\"What a mysterious bamboo it is!,\" he said."
|
||||
15 "He cuts it, then there was a small cute baby girl in it."
|
||||
15 "He cut it, then there was a small cute baby girl in it."
|
||||
16 "The girl was shining faintly."
|
||||
17 "He thought this baby girl is a gift from Heaven and took her home.\n"
|
||||
18 "His wife was surprized at his tale."
|
||||
|
@ -76,7 +76,7 @@ You can add or delete any character on GtkTextview.
|
|||
And your change is kept in GtkTextBuffer.
|
||||
If you add more characters than the limit of the window, the height of the window extends.
|
||||
If the height gets bigger than the height of the display screen, you won't be able to control the size of the window back to the original size.
|
||||
It's a problem.
|
||||
It's a problem and it shows that there exists a bug in the program.
|
||||
You can solve it by putting GtkScrolledWindow between GtkApplicationWindow and GtkTextView.
|
||||
|
||||
### GtkScrolledWindow
|
||||
|
@ -84,12 +84,12 @@ You can solve it by putting GtkScrolledWindow between GtkApplicationWindow and G
|
|||
What we need to do is:
|
||||
|
||||
- Generate GtkScrolledWindow and set it as a child of GtkApplicationWindow.
|
||||
- Set GtkTextVies as a child of GtkScrolledWindow.
|
||||
- Set GtkTextView as a child of GtkScrolledWindow.
|
||||
|
||||
Modify `tfv1.c` and save it as `tfv2.c`.
|
||||
The difference between these two files is very little.
|
||||
|
||||
$ diff tfv1.c tfv2.c
|
||||
$ cd tfv; diff tfv1.c tfv2.c
|
||||
5a6
|
||||
> GtkWidget *scr;
|
||||
24a26,28
|
||||
|
@ -122,7 +122,7 @@ Though you can modify the source file by this diff output, It's good for you to
|
|||
13 "It is a japanese word that means a man whose work is making bamboo baskets.\n"
|
||||
14 "One day, he went into a mountain and found a shining bamboo."
|
||||
15 "\"What a mysterious bamboo it is!,\" he said."
|
||||
16 "He cuts it, then there was a small cute baby girl in it."
|
||||
16 "He cut it, then there was a small cute baby girl in it."
|
||||
17 "The girl was shining faintly."
|
||||
18 "He thought this baby girl is a gift from Heaven and took her home.\n"
|
||||
19 "His wife was surprized at his tale."
|
||||
|
|
2
sec5.md
2
sec5.md
|
@ -127,7 +127,7 @@ The program is as follows.
|
|||
37 } else {
|
||||
38 filename = g_file_get_path (files[0]);
|
||||
39 g_print ("No such file: %s.\n", filename);
|
||||
40 gtk_window_destroy (GTK_WINDOW (win));
|
||||
40 gtk_window_destroy (GTK_WINDOW (win));
|
||||
41 }
|
||||
42 }
|
||||
43
|
||||
|
|
0
src/misc/comp
Executable file → Normal file
0
src/misc/comp
Executable file → Normal file
|
@ -8,7 +8,7 @@ GtkTextview is a widget for multiline text editing.
|
|||
GtkTextBuffer is a text buffer which is connected to GtkTextView.
|
||||
See a sample program `tfv1.c` below.
|
||||
|
||||
@@@ tfv1.c
|
||||
@@@ tfv/tfv1.c
|
||||
|
||||
Look at line 25.
|
||||
GtkTextView is generated and its pointer is assigned to `tv`.
|
||||
|
@ -30,7 +30,7 @@ You can add or delete any character on GtkTextview.
|
|||
And your change is kept in GtkTextBuffer.
|
||||
If you add more characters than the limit of the window, the height of the window extends.
|
||||
If the height gets bigger than the height of the display screen, you won't be able to control the size of the window back to the original size.
|
||||
It's a problem.
|
||||
It's a problem and it shows that there exists a bug in the program.
|
||||
You can solve it by putting GtkScrolledWindow between GtkApplicationWindow and GtkTextView.
|
||||
|
||||
### GtkScrolledWindow
|
||||
|
@ -38,18 +38,18 @@ You can solve it by putting GtkScrolledWindow between GtkApplicationWindow and G
|
|||
What we need to do is:
|
||||
|
||||
- Generate GtkScrolledWindow and set it as a child of GtkApplicationWindow.
|
||||
- Set GtkTextVies as a child of GtkScrolledWindow.
|
||||
- Set GtkTextView as a child of GtkScrolledWindow.
|
||||
|
||||
Modify `tfv1.c` and save it as `tfv2.c`.
|
||||
The difference between these two files is very little.
|
||||
|
||||
$$$
|
||||
diff tfv1.c tfv2.c
|
||||
cd tfv; diff tfv1.c tfv2.c
|
||||
$$$
|
||||
|
||||
Though you can modify the source file by this diff output, It's good for you to show `tfv2.c`.
|
||||
|
||||
@@@ tfv2.c
|
||||
@@@ tfv/tfv2.c
|
||||
|
||||
Now compile and run it.
|
||||
This time the window doesn't extend even if you type a lot of characters.
|
||||
|
|
|
@ -87,7 +87,7 @@ It works as follows.
|
|||
|
||||
The program is as follows.
|
||||
|
||||
@@@ tfv3.c
|
||||
@@@ tfv/tfv3.c
|
||||
|
||||
Save it as `tfv3.c`.
|
||||
Then compile and run it.
|
||||
|
@ -154,7 +154,7 @@ It is shown in the right screenshot.
|
|||
GtkNotebook widget is between GtkApplicationWindow and GtkScrolledWindow.
|
||||
Now I want to show you the program `tfv4.c`.
|
||||
|
||||
@@@ tfv4.c
|
||||
@@@ tfv/tfv4.c
|
||||
|
||||
Most of the change is in the function `on_open`.
|
||||
The numbers at the left of the following items are line numbers in the source code.
|
||||
|
|
BIN
src/tfv/a.out
Executable file
BIN
src/tfv/a.out
Executable file
Binary file not shown.
1
src/tfv/comp
Normal file
1
src/tfv/comp
Normal file
|
@ -0,0 +1 @@
|
|||
gcc `pkg-config --cflags gtk4` $1.c `pkg-config --libs gtk4`
|
|
@ -12,7 +12,7 @@ on_activate (GApplication *app, gpointer user_data) {
|
|||
"It is a japanese word that means a man whose work is making bamboo baskets.\n"
|
||||
"One day, he went into a mountain and found a shining bamboo."
|
||||
"\"What a mysterious bamboo it is!,\" he said."
|
||||
"He cuts it, then there was a small cute baby girl in it."
|
||||
"He cut it, then there was a small cute baby girl in it."
|
||||
"The girl was shining faintly."
|
||||
"He thought this baby girl is a gift from Heaven and took her home.\n"
|
||||
"His wife was surprized at his tale."
|
|
@ -13,7 +13,7 @@ on_activate (GApplication *app, gpointer user_data) {
|
|||
"It is a japanese word that means a man whose work is making bamboo baskets.\n"
|
||||
"One day, he went into a mountain and found a shining bamboo."
|
||||
"\"What a mysterious bamboo it is!,\" he said."
|
||||
"He cuts it, then there was a small cute baby girl in it."
|
||||
"He cut it, then there was a small cute baby girl in it."
|
||||
"The girl was shining faintly."
|
||||
"He thought this baby girl is a gift from Heaven and took her home.\n"
|
||||
"His wife was surprized at his tale."
|
|
@ -37,7 +37,7 @@ on_open (GApplication *app, GFile ** files, gint n_files, gchar *hint, gpointer
|
|||
} else {
|
||||
filename = g_file_get_path (files[0]);
|
||||
g_print ("No such file: %s.\n", filename);
|
||||
gtk_window_destroy (GTK_WINDOW (win));
|
||||
gtk_window_destroy (GTK_WINDOW (win));
|
||||
}
|
||||
}
|
||||
|
0
src2md.rb
Executable file → Normal file
0
src2md.rb
Executable file → Normal file
Loading…
Reference in a new issue