Files
Muse b728bccf02 Import FDesigner round-3 tree as designer/ (combined IDE, part 2)
Snapshot of cfree HEAD 1e2e6f8 (verified: src/main.cpp and Makefile
match git show HEAD byte-for-byte): separate top-level code window
(red-dot breakpoints, auto variable inspection, red paused line),
separate top-level palette window (tight 2-column grid, 36 buttons),
GDB stepping debugger, CMake support, 36-widget GTK designer.
LICENSE dropped — byte-identical to the repo MIT LICENSE.
Uncommitted palette-icons work in /opt/cfree is NOT included;
it will be re-synced before the final push if it lands.
2026-11-25 15:45:18 -05:00

51 lines
1.8 KiB
C++

// Debugger test target: small GTK app with a button callback.
// The button auto-clicks itself 800 ms after startup (so the test can
// drive it headlessly under Xvfb), and the app quits 4 s after startup.
// Compile with: g++ -g -O0 -o gtkapp gtkapp.cpp $(pkg-config --cflags --libs gtk+-3.0)
#include <gtk/gtk.h>
#include <cstdio>
static int counter = 0;
static GtkWidget* label = nullptr;
static GtkWidget* button = nullptr;
static void on_clicked(GtkButton*, gpointer) {
int before = counter; // MARK:CB
counter = before + 1; // MARK:CB_NEXT
char buf[64];
std::snprintf(buf, sizeof buf, "Clicks: %d", counter);
gtk_label_set_text(GTK_LABEL(label), buf);
}
static gboolean auto_click(gpointer) {
gtk_button_clicked(GTK_BUTTON(button));
return G_SOURCE_REMOVE;
}
static gboolean quit_app(gpointer) {
gtk_main_quit();
return G_SOURCE_REMOVE;
}
int main(int argc, char** argv) {
gtk_init(&argc, &argv);
GtkWidget* win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(win), "Debugger GTK Test");
gtk_window_set_default_size(GTK_WINDOW(win), 300, 120);
g_signal_connect(win, "destroy", G_CALLBACK(gtk_main_quit), nullptr);
GtkWidget* box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add(GTK_CONTAINER(win), box);
label = gtk_label_new("Clicks: 0");
gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0);
button = gtk_button_new_with_label("Click me");
g_signal_connect(button, "clicked", G_CALLBACK(on_clicked), nullptr);
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
gtk_widget_show_all(win);
g_timeout_add(800, auto_click, nullptr);
g_timeout_add(4000, quit_app, nullptr);
gtk_main();
std::printf("CLICKS=%d\n", counter);
std::fflush(stdout);
return 0;
}