From 15f28a82dfd3e1c469ed3aa77aa9f431ba16908b Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Fri, 21 Mar 2025 15:17:28 +0300 Subject: Consistently use gtk3/4 suffixes instead of numeric suffixes --- .gitignore | 4 ++-- Makefile | 16 +++++++------- README.md | 8 +++---- cmd/demo-gtk3/main.ha | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ cmd/demo-gtk4/main.ha | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/demo3/main.ha | 57 ------------------------------------------------- cmd/demo4/main.ha | 59 --------------------------------------------------- scripts/generate-gtk3 | 36 +++++++++++++++++++++++++++++++ scripts/generate-gtk4 | 43 +++++++++++++++++++++++++++++++++++++ scripts/generate3 | 36 ------------------------------- scripts/generate4 | 43 ------------------------------------- 11 files changed, 209 insertions(+), 209 deletions(-) create mode 100644 cmd/demo-gtk3/main.ha create mode 100644 cmd/demo-gtk4/main.ha delete mode 100644 cmd/demo3/main.ha delete mode 100644 cmd/demo4/main.ha create mode 100755 scripts/generate-gtk3 create mode 100755 scripts/generate-gtk4 delete mode 100755 scripts/generate3 delete mode 100755 scripts/generate4 diff --git a/.gitignore b/.gitignore index 6245975..91dc415 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ /xmltree /hare-gi -/demo3 -/demo4 +/demo-gtk3 +/demo-gtk4 /.gen _generated.ha diff --git a/Makefile b/Makefile index 9338dff..473649f 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,8 @@ hare-gi: $(HARE_GI_SRC) $(GIR_SRC) $(FORMAT_FASTXML_SRC) hare build -o $@ cmd/hare-gi/ .gen: hare-gi - ./scripts/generate3 - ./scripts/generate4 + ./scripts/generate-gtk3 + ./scripts/generate-gtk4 touch .gen install: hare-gi install-core install-gtk-shared install-gtk3 install-gtk4 @@ -78,16 +78,16 @@ uninstall-gtk3: uninstall-gtk4: @./scripts/uninstall-modules "$(DESTDIR)$(THIRDPARTYDIR)" $(MODULES_GTK4) -demo3: .gen - hare build $(LIBS_3) -o demo3 cmd/demo3 +demo-gtk3: .gen + hare build $(LIBS_3) -o demo-gtk3 cmd/demo-gtk3 -demo4: .gen - hare build $(LIBS_4) -o demo4 cmd/demo4 +demo-gtk4: .gen + hare build $(LIBS_4) -o demo-gtk4 cmd/demo-gtk4 clean: - rm -f hare-gi xmltree demo3 demo4 gi/*/_generate.ha + rm -f hare-gi xmltree demo-gtk3 demo-gtk4 gi/*/_generate.ha .PHONY: all clean .PHONY: install install-core install-gtk-shared install-gtk3 install-gtk4 .PHONY: uninstall uninstall-core uninstall-gtk-shared uninstall-gtk3 uninstall-gtk4 -.PHONY: demo3 demo4 +.PHONY: demo-gtk3 demo-gtk4 diff --git a/README.md b/README.md index a55f405..d69e5bb 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,14 @@ $ make ## Running examples ### GTK 3 ``` -make demo3 -./demo3 +make demo-gtk3 +./demo-gtk3 ``` ### GTK 4 ``` -make demo4 -./demo4 +make demo-gtk4 +./demo-gtk4 ``` ## Contributing diff --git a/cmd/demo-gtk3/main.ha b/cmd/demo-gtk3/main.ha new file mode 100644 index 0000000..a106b5c --- /dev/null +++ b/cmd/demo-gtk3/main.ha @@ -0,0 +1,57 @@ +use gi::gio; +use gi::glib; +use gi::gobject; +use gi::gtk; +use os; +use rt; +use types::c; + +fn about_clicked(btn: *gtk::Button, data: *opaque) void = { + let dialog = gtk::about_dialog_new(): *gtk::AboutDialog; + const authors: []*c::char = [ + c::nulstr("Harriet?\0"), + null: *c::char, + ]; + gtk::about_dialog_set_license_type( + dialog, + gtk::License::MPL_2_0, + ); + gtk::about_dialog_set_authors( + dialog, + authors: *[*]*c::char: **c::char, + ); + gtk::about_dialog_set_website( + dialog, + c::nulstr("https://git.sr.ht/~yerinalexey/hare-gi\0"), + ); + gtk::widget_show_all(dialog); +}; + +fn activate(app: *gio::Application, data: *opaque) void = { + const app = app: *gtk::Application; + + let button = gtk::button_new_with_label(c::nulstr("About\0")): *gtk::Button; + gtk::button_connect_clicked(button, &about_clicked, null); + + let headerbar = gtk::header_bar_new(): *gtk::HeaderBar; + gtk::header_bar_set_title(headerbar, c::nulstr("hare-gi demo\0")); + gtk::header_bar_set_show_close_button(headerbar, glib::TRUE); + gtk::header_bar_pack_end(headerbar, button); + + let window = gtk::application_window_new(app): *gtk::ApplicationWindow; + gtk::window_set_titlebar(window, headerbar); + gtk::widget_show_all(window); +}; + +export fn main() void = { + let app = gtk::application_new( + c::nulstr("hare_gi.example\0"), + gio::ApplicationFlags::FLAGS_NONE, + ): *gtk::Application; + gio::application_connect_activate(app, &activate, null); + const status = gio::application_run( + app, rt::argc: int, rt::argv: **c::char, + ); + gobject::object_unref(app); + os::exit(status); +}; diff --git a/cmd/demo-gtk4/main.ha b/cmd/demo-gtk4/main.ha new file mode 100644 index 0000000..39ca4ca --- /dev/null +++ b/cmd/demo-gtk4/main.ha @@ -0,0 +1,59 @@ +use gi::gio; +use gi::glib; +use gi::gobject; +use gi::gtk4; +use os; +use rt; +use types::c; + +fn about_clicked(btn: *gtk4::Button, data: *opaque) void = { + let dialog = gtk4::about_dialog_new(); + const authors: []*c::char = [ + c::nulstr("Harriet?\0"), + null: *c::char, + ]; + gtk4::about_dialog_set_license_type( + dialog: *gtk4::AboutDialog, + gtk4::License::MPL_2_0, + ); + gtk4::about_dialog_set_authors( + dialog: *gtk4::AboutDialog, + authors: *[*]*c::char: **c::char, + ); + gtk4::about_dialog_set_website( + dialog: *gtk4::AboutDialog, + c::nulstr("https://git.sr.ht/~yerinalexey/hare-gi\0"), + ); + + gtk4::widget_show(dialog); +}; + +fn activate(app: *gio::Application, data: *opaque) void = { + const app = app: *gtk4::Application; + + let button = gtk4::button_new_with_label(c::nulstr("About\0")); + gtk4::button_connect_clicked(button: *gtk4::Button, &about_clicked, null); + + let headerbar = gtk4::header_bar_new(); + let title = gtk4::label_new(c::nulstr("hare-gi demo\0")); + gtk4::header_bar_set_title_widget(headerbar: *gtk4::HeaderBar, title); + gtk4::header_bar_set_show_title_buttons(headerbar: *gtk4::HeaderBar, glib::TRUE); + gtk4::header_bar_pack_end(headerbar: *gtk4::HeaderBar, button); + + let window = gtk4::application_window_new(app); + gtk4::window_set_titlebar(window: *gtk4::Window, headerbar); + gtk4::widget_show(window); +}; + +export fn main() void = { + let app = gtk4::application_new( + c::nulstr("hare_gi.example\0"), + gio::ApplicationFlags::FLAGS_NONE, + ): *gio::Application; + gio::application_connect_activate(app, &activate, null); + const status = gio::application_run( + app, rt::argc: int, rt::argv: **c::char, + ); + gobject::object_unref(app); + os::exit(status); +}; diff --git a/cmd/demo3/main.ha b/cmd/demo3/main.ha deleted file mode 100644 index a106b5c..0000000 --- a/cmd/demo3/main.ha +++ /dev/null @@ -1,57 +0,0 @@ -use gi::gio; -use gi::glib; -use gi::gobject; -use gi::gtk; -use os; -use rt; -use types::c; - -fn about_clicked(btn: *gtk::Button, data: *opaque) void = { - let dialog = gtk::about_dialog_new(): *gtk::AboutDialog; - const authors: []*c::char = [ - c::nulstr("Harriet?\0"), - null: *c::char, - ]; - gtk::about_dialog_set_license_type( - dialog, - gtk::License::MPL_2_0, - ); - gtk::about_dialog_set_authors( - dialog, - authors: *[*]*c::char: **c::char, - ); - gtk::about_dialog_set_website( - dialog, - c::nulstr("https://git.sr.ht/~yerinalexey/hare-gi\0"), - ); - gtk::widget_show_all(dialog); -}; - -fn activate(app: *gio::Application, data: *opaque) void = { - const app = app: *gtk::Application; - - let button = gtk::button_new_with_label(c::nulstr("About\0")): *gtk::Button; - gtk::button_connect_clicked(button, &about_clicked, null); - - let headerbar = gtk::header_bar_new(): *gtk::HeaderBar; - gtk::header_bar_set_title(headerbar, c::nulstr("hare-gi demo\0")); - gtk::header_bar_set_show_close_button(headerbar, glib::TRUE); - gtk::header_bar_pack_end(headerbar, button); - - let window = gtk::application_window_new(app): *gtk::ApplicationWindow; - gtk::window_set_titlebar(window, headerbar); - gtk::widget_show_all(window); -}; - -export fn main() void = { - let app = gtk::application_new( - c::nulstr("hare_gi.example\0"), - gio::ApplicationFlags::FLAGS_NONE, - ): *gtk::Application; - gio::application_connect_activate(app, &activate, null); - const status = gio::application_run( - app, rt::argc: int, rt::argv: **c::char, - ); - gobject::object_unref(app); - os::exit(status); -}; diff --git a/cmd/demo4/main.ha b/cmd/demo4/main.ha deleted file mode 100644 index 39ca4ca..0000000 --- a/cmd/demo4/main.ha +++ /dev/null @@ -1,59 +0,0 @@ -use gi::gio; -use gi::glib; -use gi::gobject; -use gi::gtk4; -use os; -use rt; -use types::c; - -fn about_clicked(btn: *gtk4::Button, data: *opaque) void = { - let dialog = gtk4::about_dialog_new(); - const authors: []*c::char = [ - c::nulstr("Harriet?\0"), - null: *c::char, - ]; - gtk4::about_dialog_set_license_type( - dialog: *gtk4::AboutDialog, - gtk4::License::MPL_2_0, - ); - gtk4::about_dialog_set_authors( - dialog: *gtk4::AboutDialog, - authors: *[*]*c::char: **c::char, - ); - gtk4::about_dialog_set_website( - dialog: *gtk4::AboutDialog, - c::nulstr("https://git.sr.ht/~yerinalexey/hare-gi\0"), - ); - - gtk4::widget_show(dialog); -}; - -fn activate(app: *gio::Application, data: *opaque) void = { - const app = app: *gtk4::Application; - - let button = gtk4::button_new_with_label(c::nulstr("About\0")); - gtk4::button_connect_clicked(button: *gtk4::Button, &about_clicked, null); - - let headerbar = gtk4::header_bar_new(); - let title = gtk4::label_new(c::nulstr("hare-gi demo\0")); - gtk4::header_bar_set_title_widget(headerbar: *gtk4::HeaderBar, title); - gtk4::header_bar_set_show_title_buttons(headerbar: *gtk4::HeaderBar, glib::TRUE); - gtk4::header_bar_pack_end(headerbar: *gtk4::HeaderBar, button); - - let window = gtk4::application_window_new(app); - gtk4::window_set_titlebar(window: *gtk4::Window, headerbar); - gtk4::widget_show(window); -}; - -export fn main() void = { - let app = gtk4::application_new( - c::nulstr("hare_gi.example\0"), - gio::ApplicationFlags::FLAGS_NONE, - ): *gio::Application; - gio::application_connect_activate(app, &activate, null); - const status = gio::application_run( - app, rt::argc: int, rt::argv: **c::char, - ); - gobject::object_unref(app); - os::exit(status); -}; diff --git a/scripts/generate-gtk3 b/scripts/generate-gtk3 new file mode 100755 index 0000000..bf57ff5 --- /dev/null +++ b/scripts/generate-gtk3 @@ -0,0 +1,36 @@ +#!/bin/sh + +BIND=./gi +NS=gi:: + +mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ + "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ + "$BIND"/pango "$BIND"/gdk "$BIND"/xlib "$BIND"/gtk + +exec ./hare-gi -B \ + -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ + -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ + -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ + -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ + -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ + -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ + -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ + -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ + -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ + -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ + -m Gdk,${NS}gdk,"$BIND"/gdk/_generated.ha \ + -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ + -m Gtk,${NS}gtk,"$BIND"/gtk/_generated.ha \ + /usr/share/gir-1.0/GLib-2.0.gir \ + /usr/share/gir-1.0/GObject-2.0.gir \ + /usr/share/gir-1.0/Gio-2.0.gir \ + /usr/share/gir-1.0/GModule-2.0.gir \ + /usr/share/gir-1.0/Atk-1.0.gir \ + /usr/share/gir-1.0/GdkPixbuf-2.0.gir \ + /usr/share/gir-1.0/freetype2-2.0.gir \ + /usr/share/gir-1.0/HarfBuzz-0.0.gir \ + /usr/share/gir-1.0/cairo-1.0.gir \ + /usr/share/gir-1.0/Pango-1.0.gir \ + /usr/share/gir-1.0/Gdk-3.0.gir \ + /usr/share/gir-1.0/xlib-2.0.gir \ + /usr/share/gir-1.0/Gtk-3.0.gir diff --git a/scripts/generate-gtk4 b/scripts/generate-gtk4 new file mode 100755 index 0000000..c285a4e --- /dev/null +++ b/scripts/generate-gtk4 @@ -0,0 +1,43 @@ +#!/bin/sh + +BIND=./gi +NS=gi:: + +mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ + "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ + "$BIND"/pango "$BIND"/pangocairo "$BIND"/gdk4 "$BIND"/xlib "$BIND"/graphene \ + "$BIND"/gsk "$BIND"/gtk4 + +exec ./hare-gi \ + -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ + -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ + -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ + -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ + -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ + -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ + -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ + -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ + -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ + -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ + -m PangoCairo,${NS}pangocairo,"$BIND"/pangocairo/_generated.ha \ + -m Gdk,${NS}gdk4,"$BIND"/gdk4/_generated.ha \ + -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ + -m Graphene,${NS}graphene,"$BIND"/graphene/_generated.ha \ + -m Gsk,${NS}gsk,"$BIND"/gsk/_generated.ha \ + -m Gtk,${NS}gtk4,"$BIND"/gtk4/_generated.ha \ + /usr/share/gir-1.0/GLib-2.0.gir \ + /usr/share/gir-1.0/GObject-2.0.gir \ + /usr/share/gir-1.0/Gio-2.0.gir \ + /usr/share/gir-1.0/GModule-2.0.gir \ + /usr/share/gir-1.0/Atk-1.0.gir \ + /usr/share/gir-1.0/GdkPixbuf-2.0.gir \ + /usr/share/gir-1.0/freetype2-2.0.gir \ + /usr/share/gir-1.0/HarfBuzz-0.0.gir \ + /usr/share/gir-1.0/cairo-1.0.gir \ + /usr/share/gir-1.0/Pango-1.0.gir \ + /usr/share/gir-1.0/PangoCairo-1.0.gir \ + /usr/share/gir-1.0/Gdk-4.0.gir \ + /usr/share/gir-1.0/xlib-2.0.gir \ + /usr/share/gir-1.0/Graphene-1.0.gir \ + /usr/share/gir-1.0/Gsk-4.0.gir \ + /usr/share/gir-1.0/Gtk-4.0.gir diff --git a/scripts/generate3 b/scripts/generate3 deleted file mode 100755 index bf57ff5..0000000 --- a/scripts/generate3 +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -BIND=./gi -NS=gi:: - -mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ - "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ - "$BIND"/pango "$BIND"/gdk "$BIND"/xlib "$BIND"/gtk - -exec ./hare-gi -B \ - -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ - -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ - -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ - -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ - -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ - -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ - -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ - -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ - -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ - -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ - -m Gdk,${NS}gdk,"$BIND"/gdk/_generated.ha \ - -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ - -m Gtk,${NS}gtk,"$BIND"/gtk/_generated.ha \ - /usr/share/gir-1.0/GLib-2.0.gir \ - /usr/share/gir-1.0/GObject-2.0.gir \ - /usr/share/gir-1.0/Gio-2.0.gir \ - /usr/share/gir-1.0/GModule-2.0.gir \ - /usr/share/gir-1.0/Atk-1.0.gir \ - /usr/share/gir-1.0/GdkPixbuf-2.0.gir \ - /usr/share/gir-1.0/freetype2-2.0.gir \ - /usr/share/gir-1.0/HarfBuzz-0.0.gir \ - /usr/share/gir-1.0/cairo-1.0.gir \ - /usr/share/gir-1.0/Pango-1.0.gir \ - /usr/share/gir-1.0/Gdk-3.0.gir \ - /usr/share/gir-1.0/xlib-2.0.gir \ - /usr/share/gir-1.0/Gtk-3.0.gir diff --git a/scripts/generate4 b/scripts/generate4 deleted file mode 100755 index c285a4e..0000000 --- a/scripts/generate4 +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -BIND=./gi -NS=gi:: - -mkdir -p "$BIND"/glib "$BIND"/gobject "$BIND"/gio "$BIND"/gmodule "$BIND"/atk \ - "$BIND"/gdkpixbuf "$BIND"/freetype "$BIND"/harfbuzz "$BIND"/cairo \ - "$BIND"/pango "$BIND"/pangocairo "$BIND"/gdk4 "$BIND"/xlib "$BIND"/graphene \ - "$BIND"/gsk "$BIND"/gtk4 - -exec ./hare-gi \ - -m GLib,${NS}glib,"$BIND"/glib/_generated.ha \ - -m GObject,${NS}gobject,"$BIND"/gobject/_generated.ha \ - -m Gio,${NS}gio,"$BIND"/gio/_generated.ha \ - -m GModule,${NS}gmodule,"$BIND"/gmodule/_generated.ha \ - -m Atk,${NS}atk,"$BIND"/atk/_generated.ha \ - -m GdkPixbuf,${NS}gdkpixbuf,"$BIND"/gdkpixbuf/_generated.ha \ - -m freetype2,${NS}freetype,"$BIND"/freetype/_generated.ha \ - -m HarfBuzz,${NS}harfbuzz,"$BIND"/harfbuzz/_generated.ha \ - -m cairo,${NS}cairo,"$BIND"/cairo/_generated.ha \ - -m Pango,${NS}pango,"$BIND"/pango/_generated.ha \ - -m PangoCairo,${NS}pangocairo,"$BIND"/pangocairo/_generated.ha \ - -m Gdk,${NS}gdk4,"$BIND"/gdk4/_generated.ha \ - -m xlib,${NS}xlib,"$BIND"/xlib/_generated.ha \ - -m Graphene,${NS}graphene,"$BIND"/graphene/_generated.ha \ - -m Gsk,${NS}gsk,"$BIND"/gsk/_generated.ha \ - -m Gtk,${NS}gtk4,"$BIND"/gtk4/_generated.ha \ - /usr/share/gir-1.0/GLib-2.0.gir \ - /usr/share/gir-1.0/GObject-2.0.gir \ - /usr/share/gir-1.0/Gio-2.0.gir \ - /usr/share/gir-1.0/GModule-2.0.gir \ - /usr/share/gir-1.0/Atk-1.0.gir \ - /usr/share/gir-1.0/GdkPixbuf-2.0.gir \ - /usr/share/gir-1.0/freetype2-2.0.gir \ - /usr/share/gir-1.0/HarfBuzz-0.0.gir \ - /usr/share/gir-1.0/cairo-1.0.gir \ - /usr/share/gir-1.0/Pango-1.0.gir \ - /usr/share/gir-1.0/PangoCairo-1.0.gir \ - /usr/share/gir-1.0/Gdk-4.0.gir \ - /usr/share/gir-1.0/xlib-2.0.gir \ - /usr/share/gir-1.0/Graphene-1.0.gir \ - /usr/share/gir-1.0/Gsk-4.0.gir \ - /usr/share/gir-1.0/Gtk-4.0.gir -- cgit 1.3.0-6-gf8a5