|
|
@@ -0,0 +1,118 @@
|
|
|
+MODULE test_lastwidgets ;
|
|
|
+
|
|
|
+(*
|
|
|
+ m2-GTK4 test - the last few widgets: GtkAssistant, GtkIconView and
|
|
|
+ GtkEmojiChooser. Requires a display.
|
|
|
+*)
|
|
|
+
|
|
|
+FROM Gio IMPORT g_application_run, g_application_quit;
|
|
|
+FROM GtkApplication IMPORT gtk_application_new;
|
|
|
+FROM GtkWindow IMPORT gtk_application_window_new, gtk_window_set_child,
|
|
|
+ gtk_window_present;
|
|
|
+FROM GtkBox IMPORT gtk_box_new, gtk_box_append;
|
|
|
+FROM GtkEnums IMPORT GtkVertical, GtkSelectionMultiple;
|
|
|
+FROM GtkLabel IMPORT gtk_label_new;
|
|
|
+FROM GtkAssistant IMPORT gtk_assistant_new, gtk_assistant_append_page,
|
|
|
+ gtk_assistant_get_n_pages, gtk_assistant_get_nth_page,
|
|
|
+ gtk_assistant_set_page_title, gtk_assistant_set_page_complete,
|
|
|
+ gtk_assistant_set_page_type, gtk_assistant_set_current_page,
|
|
|
+ gtk_assistant_get_current_page, gtk_assistant_previous_page,
|
|
|
+ gtk_assistant_commit, AssistantPageContent;
|
|
|
+FROM GtkIconView IMPORT gtk_icon_view_new, gtk_icon_view_set_columns,
|
|
|
+ gtk_icon_view_get_columns, gtk_icon_view_set_text_column,
|
|
|
+ gtk_icon_view_get_text_column, gtk_icon_view_set_item_width,
|
|
|
+ gtk_icon_view_set_spacing, gtk_icon_view_set_selection_mode;
|
|
|
+FROM GtkEmojiChooser IMPORT gtk_emoji_chooser_new;
|
|
|
+FROM GtkUtils IMPORT Connect;
|
|
|
+FROM SYSTEM IMPORT ADDRESS, ADR;
|
|
|
+FROM libc IMPORT printf;
|
|
|
+
|
|
|
+CONST
|
|
|
+ AppId = "org.example.m2gtk4.TestLastWidgets";
|
|
|
+
|
|
|
+VAR
|
|
|
+ app: ADDRESS;
|
|
|
+ passed: BOOLEAN;
|
|
|
+
|
|
|
+PROCEDURE OnActivate (application: ADDRESS; data: ADDRESS);
|
|
|
+VAR
|
|
|
+ window, box, assistant, p1, p2, iconview, emoji: ADDRESS;
|
|
|
+ ok: BOOLEAN;
|
|
|
+BEGIN
|
|
|
+ ok := TRUE;
|
|
|
+
|
|
|
+ (* GtkAssistant *)
|
|
|
+ assistant := gtk_assistant_new();
|
|
|
+ IF assistant = NIL THEN printf("assistant NIL\n"); ok := FALSE END;
|
|
|
+ p1 := gtk_label_new("Step one");
|
|
|
+ p2 := gtk_label_new("Step two");
|
|
|
+ IF gtk_assistant_append_page(assistant, p1) # 0 THEN
|
|
|
+ printf("first page index wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ IF gtk_assistant_append_page(assistant, p2) # 1 THEN
|
|
|
+ printf("second page index wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ IF gtk_assistant_get_n_pages(assistant) # 2 THEN
|
|
|
+ printf("assistant page count wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ IF gtk_assistant_get_nth_page(assistant, 1) # p2 THEN
|
|
|
+ printf("assistant nth page wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ gtk_assistant_set_page_title(assistant, p1, "One");
|
|
|
+ gtk_assistant_set_page_complete(assistant, p1, 1);
|
|
|
+ gtk_assistant_set_page_type(assistant, p1, AssistantPageContent);
|
|
|
+ gtk_assistant_set_current_page(assistant, 1);
|
|
|
+ IF gtk_assistant_get_current_page(assistant) # 1 THEN
|
|
|
+ printf("assistant current page wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ gtk_assistant_commit(assistant);
|
|
|
+
|
|
|
+ (* GtkIconView *)
|
|
|
+ iconview := gtk_icon_view_new();
|
|
|
+ IF iconview = NIL THEN printf("icon view NIL\n"); ok := FALSE END;
|
|
|
+ gtk_icon_view_set_columns(iconview, 3);
|
|
|
+ IF gtk_icon_view_get_columns(iconview) # 3 THEN
|
|
|
+ printf("icon view columns wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ gtk_icon_view_set_text_column(iconview, 0);
|
|
|
+ IF gtk_icon_view_get_text_column(iconview) # 0 THEN
|
|
|
+ printf("icon view text column wrong\n"); ok := FALSE
|
|
|
+ END;
|
|
|
+ gtk_icon_view_set_item_width(iconview, 64);
|
|
|
+ gtk_icon_view_set_spacing(iconview, 6);
|
|
|
+ gtk_icon_view_set_selection_mode(iconview, GtkSelectionMultiple);
|
|
|
+
|
|
|
+ (* GtkEmojiChooser *)
|
|
|
+ emoji := gtk_emoji_chooser_new();
|
|
|
+ IF emoji = NIL THEN printf("emoji chooser NIL\n"); ok := FALSE END;
|
|
|
+
|
|
|
+ box := gtk_box_new(GtkVertical, 4);
|
|
|
+ gtk_box_append(box, iconview);
|
|
|
+ window := gtk_application_window_new(application);
|
|
|
+ gtk_window_set_child(window, box);
|
|
|
+ gtk_window_present(window);
|
|
|
+
|
|
|
+ passed := ok;
|
|
|
+ g_application_quit(application)
|
|
|
+END OnActivate;
|
|
|
+
|
|
|
+VAR
|
|
|
+ rc: INTEGER;
|
|
|
+BEGIN
|
|
|
+ passed := FALSE;
|
|
|
+ app := gtk_application_new(AppId, 0);
|
|
|
+ IF app = NIL THEN
|
|
|
+ printf("test_lastwidgets: FAIL (no app)\n");
|
|
|
+ HALT(1)
|
|
|
+ END;
|
|
|
+ Connect(app, "activate", ADR(OnActivate), NIL);
|
|
|
+ rc := g_application_run(app, 0, NIL);
|
|
|
+
|
|
|
+ IF passed THEN
|
|
|
+ printf("test_lastwidgets: PASS\n");
|
|
|
+ HALT(0)
|
|
|
+ ELSE
|
|
|
+ printf("test_lastwidgets: FAIL\n");
|
|
|
+ HALT(1)
|
|
|
+ END
|
|
|
+END test_lastwidgets.
|