DemosChooser.mod 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. IMPLEMENTATION MODULE DemosChooser ;
  2. (*
  3. See the GTK C originals in gtk/demos/gtk-demo:
  4. combobox.c -> DoComboBox
  5. entry_completion.c -> DoEntryCompletion
  6. entry_undo.c -> DoEntryUndo
  7. dialog.c -> DoDialog
  8. The gtk-demo contract is: on the first call build the window and store
  9. it in a module-level variable; on later calls just toggle the window's
  10. visibility, destroying it (and clearing the variable) when it is
  11. already visible. Return the window, or NIL once destroyed.
  12. None of the deprecated, model-based widgets these demos use are
  13. exposed under src/ (GtkComboBox, GtkComboBoxText, GtkTreeModel,
  14. GtkListStore, GtkTreeStore, GtkCellRenderer, GtkCellLayout), and
  15. neither are GtkDialog / GtkMessageDialog. Each affected spot is
  16. adapted to a bound equivalent and marked SIMPLIFIED below:
  17. * combobox: the four combo boxes become GtkDropDown widgets over a
  18. GtkStringList (the documented modern replacement). The icon
  19. renderer, the row separator, the insensitive rows and the
  20. GtkTreeStore hierarchy cannot be reproduced, so the "Items with
  21. icons" frame lists its five labels and the "Where are we ?" frame
  22. lists the capitals of its tree flattened. The editable combo is
  23. a drop-down with search enabled; the "String IDs" property
  24. binding (g_object_bind_property, unbound) is emulated by wiring
  25. the drop-down's "notify::selected" and the entry's "changed"
  26. signals together.
  27. * entry_completion: GtkEntryCompletion is bound, but the
  28. GtkTreeModel/GtkListStore it needs for its items is not, so the
  29. completion is created with a text column but no model. The
  30. inline-completion and inline-selection setters are not bound
  31. either.
  32. * entry_undo: gtk_editable_set_enable_undo() is not bound, so the
  33. entry is created without enabling undo/redo.
  34. * dialog: GtkDialog/GtkMessageDialog are replaced by
  35. AdwMessageDialog (responses plus an extra child); plain labels
  36. stand in for the mnemonic labels, whose setters
  37. (gtk_label_new_with_mnemonic / gtk_label_set_mnemonic_widget) are
  38. not bound.
  39. *)
  40. FROM SYSTEM IMPORT ADDRESS, ADR;
  41. FROM GtkWindow IMPORT gtk_window_new, gtk_window_set_title,
  42. gtk_window_set_resizable, gtk_window_set_child, gtk_window_destroy,
  43. gtk_window_present;
  44. FROM GtkWidget IMPORT gtk_widget_set_visible, gtk_widget_get_visible,
  45. gtk_widget_set_margin_start, gtk_widget_set_margin_end,
  46. gtk_widget_set_margin_top, gtk_widget_set_margin_bottom,
  47. gtk_widget_set_hexpand, gtk_widget_set_vexpand,
  48. gtk_widget_set_halign, gtk_widget_set_valign;
  49. FROM GtkEnums IMPORT GtkVertical, GtkHorizontal, GtkAlignCenter;
  50. FROM GtkBox IMPORT gtk_box_new, gtk_box_append;
  51. FROM GtkFrame IMPORT gtk_frame_new, gtk_frame_set_child;
  52. FROM GtkLabel IMPORT gtk_label_new, gtk_label_set_markup;
  53. FROM GtkGrid IMPORT gtk_grid_new, gtk_grid_attach,
  54. gtk_grid_set_row_spacing, gtk_grid_set_column_spacing;
  55. FROM GtkSeparator IMPORT gtk_separator_new;
  56. FROM GtkButton IMPORT gtk_button_new_with_mnemonic;
  57. FROM GtkEntry IMPORT gtk_entry_new, gtk_entry_set_completion;
  58. FROM GtkEntryCompletion IMPORT gtk_entry_completion_new,
  59. gtk_entry_completion_set_text_column,
  60. gtk_entry_completion_set_popup_completion;
  61. FROM GtkEditable IMPORT gtk_editable_get_text, gtk_editable_set_text;
  62. FROM GtkDropDown IMPORT gtk_drop_down_new, gtk_drop_down_set_selected,
  63. gtk_drop_down_get_selected, gtk_drop_down_get_model,
  64. gtk_drop_down_set_enable_search;
  65. FROM GtkStringList IMPORT gtk_string_list_new, gtk_string_list_append,
  66. gtk_string_list_get_string;
  67. FROM AdwMessageDialog IMPORT adw_message_dialog_new,
  68. adw_message_dialog_add_response, adw_message_dialog_set_default_response,
  69. adw_message_dialog_set_extra_child;
  70. FROM GtkClosures IMPORT Connect2, Connect3;
  71. FROM GtkUtils IMPORT IntToStr, CStrToM2, StrAppend;
  72. FROM GLib IMPORT g_strcmp0;
  73. (* ================================================================== *)
  74. (* combobox *)
  75. (* ================================================================== *)
  76. VAR
  77. comboWindow: ADDRESS;
  78. comboStringEntry: ADDRESS; (* entry of the "String IDs" frame *)
  79. comboIdsDropDown: ADDRESS; (* drop-down of the "String IDs" frame *)
  80. (* Keep the two sides of the (unbound) active-id <-> text property
  81. binding in sync: selecting a drop-down item writes the entry, and
  82. typing an exact item writes the drop-down. *)
  83. PROCEDURE OnComboSelected (dropdown: ADDRESS; pspec: ADDRESS; data: ADDRESS);
  84. VAR
  85. model, item: ADDRESS;
  86. buf: ARRAY [0..63] OF CHAR;
  87. BEGIN
  88. model := gtk_drop_down_get_model(dropdown);
  89. item := gtk_string_list_get_string(model, gtk_drop_down_get_selected(dropdown));
  90. CStrToM2(item, buf);
  91. gtk_editable_set_text(comboStringEntry, buf)
  92. END OnComboSelected;
  93. PROCEDURE OnComboEntryChanged (entry: ADDRESS; data: ADDRESS);
  94. VAR
  95. model, item: ADDRESS;
  96. text, buf: ARRAY [0..63] OF CHAR;
  97. i: INTEGER;
  98. BEGIN
  99. CStrToM2(gtk_editable_get_text(entry), text);
  100. model := gtk_drop_down_get_model(comboIdsDropDown);
  101. FOR i := 0 TO 2 DO
  102. item := gtk_string_list_get_string(model, VAL(CARDINAL, i));
  103. CStrToM2(item, buf);
  104. IF g_strcmp0(ADR(text), ADR(buf)) = 0 THEN
  105. gtk_drop_down_set_selected(comboIdsDropDown, VAL(CARDINAL, i));
  106. RETURN
  107. END
  108. END
  109. END OnComboEntryChanged;
  110. (* The capitals of create_capital_store(), flattened (the group rows and
  111. the tree shape are lost with GtkTreeStore unbound). Index 8 is
  112. Boston, which is what the C demo selects via path (0, 8). *)
  113. PROCEDURE AddCapitals (list: ADDRESS);
  114. BEGIN
  115. gtk_string_list_append(list, "Albany");
  116. gtk_string_list_append(list, "Annapolis");
  117. gtk_string_list_append(list, "Atlanta");
  118. gtk_string_list_append(list, "Augusta");
  119. gtk_string_list_append(list, "Austin");
  120. gtk_string_list_append(list, "Baton Rouge");
  121. gtk_string_list_append(list, "Bismarck");
  122. gtk_string_list_append(list, "Boise");
  123. gtk_string_list_append(list, "Boston");
  124. gtk_string_list_append(list, "Carson City");
  125. gtk_string_list_append(list, "Charleston");
  126. gtk_string_list_append(list, "Cheyenne");
  127. gtk_string_list_append(list, "Columbia");
  128. gtk_string_list_append(list, "Columbus");
  129. gtk_string_list_append(list, "Concord");
  130. gtk_string_list_append(list, "Denver");
  131. gtk_string_list_append(list, "Des Moines");
  132. gtk_string_list_append(list, "Dover");
  133. gtk_string_list_append(list, "Frankfort");
  134. gtk_string_list_append(list, "Harrisburg");
  135. gtk_string_list_append(list, "Hartford");
  136. gtk_string_list_append(list, "Helena");
  137. gtk_string_list_append(list, "Honolulu");
  138. gtk_string_list_append(list, "Indianapolis");
  139. gtk_string_list_append(list, "Jackson");
  140. gtk_string_list_append(list, "Jefferson City");
  141. gtk_string_list_append(list, "Juneau");
  142. gtk_string_list_append(list, "Lansing");
  143. gtk_string_list_append(list, "Lincoln");
  144. gtk_string_list_append(list, "Little Rock");
  145. gtk_string_list_append(list, "Madison");
  146. gtk_string_list_append(list, "Montgomery");
  147. gtk_string_list_append(list, "Montpelier");
  148. gtk_string_list_append(list, "Nashville");
  149. gtk_string_list_append(list, "Oklahoma City");
  150. gtk_string_list_append(list, "Olympia");
  151. gtk_string_list_append(list, "Phoenix");
  152. gtk_string_list_append(list, "Pierre");
  153. gtk_string_list_append(list, "Providence");
  154. gtk_string_list_append(list, "Raleigh");
  155. gtk_string_list_append(list, "Richmond");
  156. gtk_string_list_append(list, "Sacramento");
  157. gtk_string_list_append(list, "Salem");
  158. gtk_string_list_append(list, "Salt Lake City");
  159. gtk_string_list_append(list, "Santa Fe");
  160. gtk_string_list_append(list, "Springfield");
  161. gtk_string_list_append(list, "St. Paul");
  162. gtk_string_list_append(list, "Tallahassee");
  163. gtk_string_list_append(list, "Topeka");
  164. gtk_string_list_append(list, "Trenton")
  165. END AddCapitals;
  166. PROCEDURE DoComboBox (doWidget: ADDRESS) : ADDRESS;
  167. VAR
  168. vbox, frame, box, combo, list: ADDRESS;
  169. BEGIN
  170. IF comboWindow = NIL THEN
  171. comboWindow := gtk_window_new();
  172. gtk_window_set_title(comboWindow, "Combo Boxes");
  173. vbox := gtk_box_new(GtkVertical, 2);
  174. gtk_widget_set_margin_start(vbox, 10);
  175. gtk_widget_set_margin_end(vbox, 10);
  176. gtk_widget_set_margin_top(vbox, 10);
  177. gtk_widget_set_margin_bottom(vbox, 10);
  178. gtk_window_set_child(comboWindow, vbox);
  179. (* Items with icons (icons, separator and insensitivity omitted) *)
  180. frame := gtk_frame_new("Items with icons");
  181. gtk_box_append(vbox, frame);
  182. box := gtk_box_new(GtkVertical, 0);
  183. gtk_widget_set_margin_start(box, 5);
  184. gtk_widget_set_margin_end(box, 5);
  185. gtk_widget_set_margin_top(box, 5);
  186. gtk_widget_set_margin_bottom(box, 5);
  187. gtk_frame_set_child(frame, box);
  188. list := gtk_string_list_new(NIL);
  189. gtk_string_list_append(list, "Warning");
  190. gtk_string_list_append(list, "Stop");
  191. gtk_string_list_append(list, "New");
  192. gtk_string_list_append(list, "Clear");
  193. gtk_string_list_append(list, "Open");
  194. combo := gtk_drop_down_new(list, NIL);
  195. gtk_drop_down_set_selected(combo, 0);
  196. gtk_box_append(box, combo);
  197. (* Where are we ? (tree flattened to its capitals) *)
  198. frame := gtk_frame_new("Where are we ?");
  199. gtk_box_append(vbox, frame);
  200. box := gtk_box_new(GtkVertical, 0);
  201. gtk_widget_set_margin_start(box, 5);
  202. gtk_widget_set_margin_end(box, 5);
  203. gtk_widget_set_margin_top(box, 5);
  204. gtk_widget_set_margin_bottom(box, 5);
  205. gtk_frame_set_child(frame, box);
  206. list := gtk_string_list_new(NIL);
  207. AddCapitals(list);
  208. combo := gtk_drop_down_new(list, NIL);
  209. gtk_drop_down_set_selected(combo, 8);
  210. gtk_box_append(box, combo);
  211. (* Editable (search stands in for the validating entry) *)
  212. frame := gtk_frame_new("Editable");
  213. gtk_box_append(vbox, frame);
  214. box := gtk_box_new(GtkVertical, 0);
  215. gtk_widget_set_margin_start(box, 5);
  216. gtk_widget_set_margin_end(box, 5);
  217. gtk_widget_set_margin_top(box, 5);
  218. gtk_widget_set_margin_bottom(box, 5);
  219. gtk_frame_set_child(frame, box);
  220. list := gtk_string_list_new(NIL);
  221. gtk_string_list_append(list, "One");
  222. gtk_string_list_append(list, "Two");
  223. gtk_string_list_append(list, "2\xC2\xBD");
  224. gtk_string_list_append(list, "Three");
  225. combo := gtk_drop_down_new(list, NIL);
  226. gtk_drop_down_set_enable_search(combo, 1);
  227. gtk_box_append(box, combo);
  228. (* String IDs (active-id binding emulated with two signals) *)
  229. frame := gtk_frame_new("String IDs");
  230. gtk_box_append(vbox, frame);
  231. box := gtk_box_new(GtkVertical, 0);
  232. gtk_widget_set_margin_start(box, 5);
  233. gtk_widget_set_margin_end(box, 5);
  234. gtk_widget_set_margin_top(box, 5);
  235. gtk_widget_set_margin_bottom(box, 5);
  236. gtk_frame_set_child(frame, box);
  237. list := gtk_string_list_new(NIL);
  238. gtk_string_list_append(list, "Not visible");
  239. gtk_string_list_append(list, "Visible when active");
  240. gtk_string_list_append(list, "Always visible");
  241. comboIdsDropDown := gtk_drop_down_new(list, NIL);
  242. gtk_box_append(box, comboIdsDropDown);
  243. comboStringEntry := gtk_entry_new();
  244. gtk_box_append(box, comboStringEntry);
  245. Connect3(comboIdsDropDown, "notify::selected", OnComboSelected, NIL);
  246. Connect2(comboStringEntry, "changed", OnComboEntryChanged, NIL)
  247. END;
  248. IF gtk_widget_get_visible(comboWindow) = 0 THEN
  249. gtk_widget_set_visible(comboWindow, 1)
  250. ELSE
  251. gtk_window_destroy(comboWindow);
  252. comboWindow := NIL;
  253. comboStringEntry := NIL;
  254. comboIdsDropDown := NIL
  255. END;
  256. RETURN comboWindow
  257. END DoComboBox;
  258. (* ================================================================== *)
  259. (* entry_completion *)
  260. (* ================================================================== *)
  261. VAR
  262. entryCompletionWindow: ADDRESS;
  263. PROCEDURE DoEntryCompletion (doWidget: ADDRESS) : ADDRESS;
  264. VAR
  265. vbox, label, entry, completion: ADDRESS;
  266. BEGIN
  267. IF entryCompletionWindow = NIL THEN
  268. entryCompletionWindow := gtk_window_new();
  269. gtk_window_set_title(entryCompletionWindow, "Completion");
  270. gtk_window_set_resizable(entryCompletionWindow, 0);
  271. vbox := gtk_box_new(GtkVertical, 12);
  272. gtk_widget_set_margin_start(vbox, 18);
  273. gtk_widget_set_margin_end(vbox, 18);
  274. gtk_widget_set_margin_top(vbox, 18);
  275. gtk_widget_set_margin_bottom(vbox, 18);
  276. gtk_window_set_child(entryCompletionWindow, vbox);
  277. label := gtk_label_new("");
  278. gtk_label_set_markup(label,
  279. "Try writing <b>total</b> or <b>gnome</b> for example.");
  280. gtk_box_append(vbox, label);
  281. entry := gtk_entry_new();
  282. gtk_box_append(vbox, entry);
  283. completion := gtk_entry_completion_new();
  284. gtk_entry_set_completion(entry, completion);
  285. (* SIMPLIFIED: GtkTreeModel/GtkListStore (the completion's model)
  286. are unbound, so there are no items to complete; only the text
  287. column and popup-completion setting survive. The C demo's
  288. inline-completion/inline-selection setters are unbound too. *)
  289. gtk_entry_completion_set_text_column(completion, 0);
  290. gtk_entry_completion_set_popup_completion(completion, 1)
  291. END;
  292. IF gtk_widget_get_visible(entryCompletionWindow) = 0 THEN
  293. gtk_widget_set_visible(entryCompletionWindow, 1)
  294. ELSE
  295. gtk_window_destroy(entryCompletionWindow);
  296. entryCompletionWindow := NIL
  297. END;
  298. RETURN entryCompletionWindow
  299. END DoEntryCompletion;
  300. (* ================================================================== *)
  301. (* entry_undo *)
  302. (* ================================================================== *)
  303. VAR
  304. entryUndoWindow: ADDRESS;
  305. PROCEDURE DoEntryUndo (doWidget: ADDRESS) : ADDRESS;
  306. VAR
  307. vbox, label, entry: ADDRESS;
  308. BEGIN
  309. IF entryUndoWindow = NIL THEN
  310. entryUndoWindow := gtk_window_new();
  311. gtk_window_set_title(entryUndoWindow, "Undo and Redo");
  312. gtk_window_set_resizable(entryUndoWindow, 0);
  313. vbox := gtk_box_new(GtkVertical, 12);
  314. gtk_widget_set_margin_start(vbox, 18);
  315. gtk_widget_set_margin_end(vbox, 18);
  316. gtk_widget_set_margin_top(vbox, 18);
  317. gtk_widget_set_margin_bottom(vbox, 18);
  318. gtk_window_set_child(entryUndoWindow, vbox);
  319. label := gtk_label_new("");
  320. gtk_label_set_markup(label,
  321. "Use Control+z or Control+Shift+z to undo or redo changes");
  322. gtk_box_append(vbox, label);
  323. entry := gtk_entry_new();
  324. (* SIMPLIFIED: gtk_editable_set_enable_undo() is not bound, so
  325. undo/redo support cannot be turned on from here. *)
  326. gtk_box_append(vbox, entry)
  327. END;
  328. IF gtk_widget_get_visible(entryUndoWindow) = 0 THEN
  329. gtk_widget_set_visible(entryUndoWindow, 1)
  330. ELSE
  331. gtk_window_destroy(entryUndoWindow);
  332. entryUndoWindow := NIL
  333. END;
  334. RETURN entryUndoWindow
  335. END DoEntryUndo;
  336. (* ================================================================== *)
  337. (* dialog *)
  338. (* ================================================================== *)
  339. VAR
  340. dialogWindow: ADDRESS;
  341. dialogEntry1, dialogEntry2: ADDRESS; (* left-hand entries *)
  342. dialogLocalEntry1, dialogLocalEntry2: ADDRESS;
  343. dialogCount: INTEGER;
  344. (* void message_dialog_clicked(GtkButton *button, gpointer user_data) *)
  345. PROCEDURE OnMessageDialog (button: ADDRESS; data: ADDRESS);
  346. VAR
  347. dialog: ADDRESS;
  348. body, num: ARRAY [0..63] OF CHAR;
  349. BEGIN
  350. INC(dialogCount);
  351. body := "Has been shown ";
  352. IntToStr(dialogCount, num);
  353. StrAppend(body, num);
  354. StrAppend(body, " times");
  355. dialog := adw_message_dialog_new(dialogWindow, "Test message", body);
  356. adw_message_dialog_add_response(dialog, "ok", "_OK");
  357. adw_message_dialog_add_response(dialog, "cancel", "_Cancel");
  358. adw_message_dialog_set_default_response(dialog, "ok");
  359. gtk_window_present(dialog)
  360. END OnMessageDialog;
  361. (* void on_dialog_response(GtkDialog *dialog, int response, gpointer data) *)
  362. PROCEDURE OnDialogResponse (dialog: ADDRESS; response: ADDRESS; data: ADDRESS);
  363. VAR
  364. ok: ARRAY [0..3] OF CHAR;
  365. text: ARRAY [0..255] OF CHAR;
  366. BEGIN
  367. ok := "ok";
  368. IF g_strcmp0(response, ADR(ok)) = 0 THEN
  369. CStrToM2(gtk_editable_get_text(dialogLocalEntry1), text);
  370. gtk_editable_set_text(dialogEntry1, text);
  371. CStrToM2(gtk_editable_get_text(dialogLocalEntry2), text);
  372. gtk_editable_set_text(dialogEntry2, text)
  373. END
  374. (* AdwMessageDialog closes itself once a response is activated. *)
  375. END OnDialogResponse;
  376. (* void interactive_dialog_clicked(GtkButton *button, gpointer user_data) *)
  377. PROCEDURE OnInteractiveDialog (button: ADDRESS; data: ADDRESS);
  378. VAR
  379. dialog, grid, label: ADDRESS;
  380. text: ARRAY [0..255] OF CHAR;
  381. BEGIN
  382. dialog := adw_message_dialog_new(dialogWindow, "Interactive Dialog", "");
  383. adw_message_dialog_add_response(dialog, "ok", "_OK");
  384. adw_message_dialog_add_response(dialog, "cancel", "_Cancel");
  385. adw_message_dialog_set_default_response(dialog, "ok");
  386. grid := gtk_grid_new();
  387. gtk_widget_set_hexpand(grid, 1);
  388. gtk_widget_set_vexpand(grid, 1);
  389. gtk_widget_set_halign(grid, GtkAlignCenter);
  390. gtk_widget_set_valign(grid, GtkAlignCenter);
  391. gtk_grid_set_row_spacing(grid, 6);
  392. gtk_grid_set_column_spacing(grid, 6);
  393. (* SIMPLIFIED: plain labels, as the mnemonic variants are unbound. *)
  394. label := gtk_label_new("Entry 1");
  395. gtk_grid_attach(grid, label, 0, 0, 1, 1);
  396. dialogLocalEntry1 := gtk_entry_new();
  397. CStrToM2(gtk_editable_get_text(dialogEntry1), text);
  398. gtk_editable_set_text(dialogLocalEntry1, text);
  399. gtk_grid_attach(grid, dialogLocalEntry1, 1, 0, 1, 1);
  400. label := gtk_label_new("Entry 2");
  401. gtk_grid_attach(grid, label, 0, 1, 1, 1);
  402. dialogLocalEntry2 := gtk_entry_new();
  403. CStrToM2(gtk_editable_get_text(dialogEntry2), text);
  404. gtk_editable_set_text(dialogLocalEntry2, text);
  405. gtk_grid_attach(grid, dialogLocalEntry2, 1, 1, 1, 1);
  406. adw_message_dialog_set_extra_child(dialog, grid);
  407. Connect3(dialog, "response", OnDialogResponse, NIL);
  408. gtk_window_present(dialog)
  409. END OnInteractiveDialog;
  410. PROCEDURE DoDialog (doWidget: ADDRESS) : ADDRESS;
  411. VAR
  412. vbox, vbox2, hbox, button, table, label: ADDRESS;
  413. BEGIN
  414. IF dialogWindow = NIL THEN
  415. dialogWindow := gtk_window_new();
  416. gtk_window_set_title(dialogWindow, "Dialogs");
  417. gtk_window_set_resizable(dialogWindow, 0);
  418. vbox := gtk_box_new(GtkVertical, 8);
  419. gtk_widget_set_margin_start(vbox, 8);
  420. gtk_widget_set_margin_end(vbox, 8);
  421. gtk_widget_set_margin_top(vbox, 8);
  422. gtk_widget_set_margin_bottom(vbox, 8);
  423. gtk_window_set_child(dialogWindow, vbox);
  424. (* Standard message dialog *)
  425. hbox := gtk_box_new(GtkHorizontal, 8);
  426. gtk_box_append(vbox, hbox);
  427. button := gtk_button_new_with_mnemonic("_Message Dialog");
  428. Connect2(button, "clicked", OnMessageDialog, NIL);
  429. gtk_box_append(hbox, button);
  430. gtk_box_append(vbox, gtk_separator_new(GtkHorizontal));
  431. (* Interactive dialog *)
  432. hbox := gtk_box_new(GtkHorizontal, 8);
  433. gtk_box_append(vbox, hbox);
  434. vbox2 := gtk_box_new(GtkVertical, 0);
  435. button := gtk_button_new_with_mnemonic("_Interactive Dialog");
  436. Connect2(button, "clicked", OnInteractiveDialog, NIL);
  437. gtk_box_append(hbox, vbox2);
  438. gtk_box_append(vbox2, button);
  439. table := gtk_grid_new();
  440. gtk_grid_set_row_spacing(table, 4);
  441. gtk_grid_set_column_spacing(table, 4);
  442. gtk_box_append(hbox, table);
  443. label := gtk_label_new("Entry 1");
  444. gtk_grid_attach(table, label, 0, 0, 1, 1);
  445. dialogEntry1 := gtk_entry_new();
  446. gtk_grid_attach(table, dialogEntry1, 1, 0, 1, 1);
  447. label := gtk_label_new("Entry 2");
  448. gtk_grid_attach(table, label, 0, 1, 1, 1);
  449. dialogEntry2 := gtk_entry_new();
  450. gtk_grid_attach(table, dialogEntry2, 1, 1, 1, 1)
  451. END;
  452. IF gtk_widget_get_visible(dialogWindow) = 0 THEN
  453. gtk_widget_set_visible(dialogWindow, 1)
  454. ELSE
  455. gtk_window_destroy(dialogWindow);
  456. dialogWindow := NIL;
  457. dialogEntry1 := NIL;
  458. dialogEntry2 := NIL;
  459. dialogLocalEntry1 := NIL;
  460. dialogLocalEntry2 := NIL
  461. END;
  462. RETURN dialogWindow
  463. END DoDialog;
  464. BEGIN
  465. comboWindow := NIL;
  466. comboStringEntry := NIL;
  467. comboIdsDropDown := NIL;
  468. entryCompletionWindow := NIL;
  469. entryUndoWindow := NIL;
  470. dialogWindow := NIL;
  471. dialogEntry1 := NIL;
  472. dialogEntry2 := NIL;
  473. dialogLocalEntry1 := NIL;
  474. dialogLocalEntry2 := NIL;
  475. dialogCount := 0
  476. END DemosChooser.