Bug fixed in list1.c, lib_src2md.rb.

This commit is contained in:
Toshio Sekiya 2021-05-14 21:34:11 +09:00
parent ee84a60e54
commit dafb10cec6
4 changed files with 69 additions and 64 deletions

View file

@ -20,8 +20,7 @@ abstract = Src_file.new "src/abstract.src.md"
otherfiles = ["src/turtle/turtle_doc.src.md", otherfiles = ["src/turtle/turtle_doc.src.md",
"src/tfetextview/tfetextview_doc.src.md", "src/tfetextview/tfetextview_doc.src.md",
"src/Readme_for_developers.src.md"] "src/Readme_for_developers.src.md"].map {|file| Src_file.new file}
otherfiles = otherfiles.map {|file| Src_file.new file}
srcfiles = secfiles + otherfiles srcfiles = secfiles + otherfiles
file_table = srcfiles.map do |srcfile| file_table = srcfiles.map do |srcfile|

View file

@ -137,63 +137,64 @@ GtkNoSelection is used, so user can't select any item.
17 17
18 static void 18 static void
19 unbind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) { 19 unbind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {
20 GtkWidget *lb = gtk_list_item_get_child (listitem); 20 /* There's nothing to do here. */
21 gtk_label_set_text (GTK_LABEL (lb), ""); 21 /* If you does something like setting a signal in bind_cb, */
22 } 22 /* then disconnecting the signal is necessary in unbind_cb. */
23 23 }
24 static void 24
25 teardown_cb (GtkListItemFactory *factory, GtkListItem *listitem, gpointer user_data) { 25 static void
26 gtk_list_item_set_child (listitem, NULL); 26 teardown_cb (GtkListItemFactory *factory, GtkListItem *listitem, gpointer user_data) {
27 /* When the child of listitem is set to NULL, the reference to GtkLabel will be released and lb will be destroyed. */ 27 gtk_list_item_set_child (listitem, NULL);
28 /* Therefore, g_object_unref () for the GtkLabel object doesn't need in the user code. */ 28 /* When the child of listitem is set to NULL, the reference to GtkLabel will be released and lb will be destroyed. */
29 } 29 /* Therefore, g_object_unref () for the GtkLabel object doesn't need in the user code. */
30 30 }
31 /* ----- activate, open, startup handlers ----- */ 31
32 static void 32 /* ----- activate, open, startup handlers ----- */
33 app_activate (GApplication *application) { 33 static void
34 GtkApplication *app = GTK_APPLICATION (application); 34 app_activate (GApplication *application) {
35 GtkWidget *win = gtk_application_window_new (app); 35 GtkApplication *app = GTK_APPLICATION (application);
36 gtk_window_set_default_size (GTK_WINDOW (win), 600, 400); 36 GtkWidget *win = gtk_application_window_new (app);
37 GtkWidget *scr = gtk_scrolled_window_new (); 37 gtk_window_set_default_size (GTK_WINDOW (win), 600, 400);
38 gtk_window_set_child (GTK_WINDOW (win), scr); 38 GtkWidget *scr = gtk_scrolled_window_new ();
39 39 gtk_window_set_child (GTK_WINDOW (win), scr);
40 char *array[] = { 40
41 "one", "two", "three", "four", NULL 41 char *array[] = {
42 }; 42 "one", "two", "three", "four", NULL
43 GtkStringList *sl = gtk_string_list_new ((const char * const *) array); 43 };
44 GtkNoSelection *ns = gtk_no_selection_new (G_LIST_MODEL (sl)); 44 GtkStringList *sl = gtk_string_list_new ((const char * const *) array);
45 45 GtkNoSelection *ns = gtk_no_selection_new (G_LIST_MODEL (sl));
46 GtkListItemFactory *factory = gtk_signal_list_item_factory_new (); 46
47 g_signal_connect (factory, "setup", G_CALLBACK (setup_cb), NULL); 47 GtkListItemFactory *factory = gtk_signal_list_item_factory_new ();
48 g_signal_connect (factory, "bind", G_CALLBACK (bind_cb), NULL); 48 g_signal_connect (factory, "setup", G_CALLBACK (setup_cb), NULL);
49 g_signal_connect (factory, "unbind", G_CALLBACK (unbind_cb), NULL); 49 g_signal_connect (factory, "bind", G_CALLBACK (bind_cb), NULL);
50 g_signal_connect (factory, "teardown", G_CALLBACK (teardown_cb), NULL); 50 g_signal_connect (factory, "unbind", G_CALLBACK (unbind_cb), NULL);
51 51 g_signal_connect (factory, "teardown", G_CALLBACK (teardown_cb), NULL);
52 GtkWidget *lv = gtk_list_view_new (GTK_SELECTION_MODEL (ns), factory); 52
53 gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scr), lv); 53 GtkWidget *lv = gtk_list_view_new (GTK_SELECTION_MODEL (ns), factory);
54 gtk_widget_show (win); 54 gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scr), lv);
55 } 55 gtk_widget_show (win);
56 56 }
57 static void 57
58 app_startup (GApplication *application) { 58 static void
59 } 59 app_startup (GApplication *application) {
60 60 }
61 /* ----- main ----- */ 61
62 int 62 /* ----- main ----- */
63 main (int argc, char **argv) { 63 int
64 GtkApplication *app; 64 main (int argc, char **argv) {
65 int stat; 65 GtkApplication *app;
66 66 int stat;
67 app = gtk_application_new ("com.github.ToshioCP.list1", G_APPLICATION_FLAGS_NONE); 67
68 68 app = gtk_application_new ("com.github.ToshioCP.list1", G_APPLICATION_FLAGS_NONE);
69 g_signal_connect (app, "startup", G_CALLBACK (app_startup), NULL); 69
70 g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL); 70 g_signal_connect (app, "startup", G_CALLBACK (app_startup), NULL);
71 71 g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL);
72 stat =g_application_run (G_APPLICATION (app), argc, argv); 72
73 g_object_unref (app); 73 stat =g_application_run (G_APPLICATION (app), argc, argv);
74 return stat; 74 g_object_unref (app);
75 } 75 return stat;
76 76 }
77
~~~ ~~~
The file `list1.c` is located under the directory [src/misc](../src/misc). The file `list1.c` is located under the directory [src/misc](../src/misc).

View file

@ -77,7 +77,7 @@ require 'pathname'
# type is "gfm", "html" or "latex". # type is "gfm", "html" or "latex".
# Caller can specify the target type. # Caller can specify the target type.
def src2md srcmd, md, file_table=nil, type="gfm" def src2md srcmd, md, file_table=nil, type=nil
# parameters: # parameters:
# srcmd: .src.md file's path. source # srcmd: .src.md file's path. source
# md: .md file's path. destination # md: .md file's path. destination
@ -85,8 +85,12 @@ def src2md srcmd, md, file_table=nil, type="gfm"
src_dir = File.dirname srcmd src_dir = File.dirname srcmd
md_dir = File.dirname md md_dir = File.dirname md
type_dir = File.basename md_dir # type of the target. gfm, html or latex type_dir = File.basename md_dir # type of the target. gfm, html or latex
if type_dir == "gfm" || type_dir == "html" || type_dir == "latex" if (type == nil || (type != "gfm" && type != "html" && type != "latex"))
type = type_dir if type_dir == "gfm" || type_dir == "html" || type_dir == "latex"
type = type_dir
else
type = "gfm" # default type
end
end end
# phase 1 # phase 1

View file

@ -17,8 +17,9 @@ bind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_da
static void static void
unbind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) { unbind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {
GtkWidget *lb = gtk_list_item_get_child (listitem); /* There's nothing to do here. */
gtk_label_set_text (GTK_LABEL (lb), ""); /* If you does something like setting a signal in bind_cb, */
/* then disconnecting the signal is necessary in unbind_cb. */
} }
static void static void