-
Notifications
You must be signed in to change notification settings - Fork 1
/
git_ex06.c
51 lines (39 loc) · 1.63 KB
/
git_ex06.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <gtk/gtk.h>
static void app_activate (GApplication *app, gpointer user_data){
GtkWidget *win;
GtkWidget *scr;
GtkWidget *tv;
GtkTextBuffer *tb;
gchar *text;
text =
"Once upon a time, there was an old man who was called Taketori-no-Okina. "
"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 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. "
"They were very happy because they had no children. ";
win = gtk_application_window_new(GTK_APPLICATION(app));
gtk_window_set_title(GTK_WINDOW(win), "GtkTextView");
gtk_window_set_default_size(GTK_WINDOW(win), 400,100);
scr = gtk_scrolled_window_new();
gtk_window_set_child(GTK_WINDOW(win), scr);
tv = gtk_text_view_new();
tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));
gtk_text_buffer_set_text(tb, text, -1);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tv), GTK_WRAP_WORD_CHAR);
gtk_text_view_set_editable(GTK_TEXT_VIEW(tv), FALSE);
gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scr), tv);
gtk_widget_show(win);
}
int main(int argc, char **argv){
GtkApplication *app;
int stat;
app = gtk_application_new("com.example.www", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(app_activate), NULL);
stat = g_application_run(G_APPLICATION(app), argc, argv);
g_object_ref(app);
return stat;
}