This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
programming:gtk4 [2022/03/20 18:36] nanodano created |
programming:gtk4 [2022/03/21 05:19] (current) nanodano |
||
---|---|---|---|
Line 58: | Line 58: | ||
# Documentation will now be in docs/ | # Documentation will now be in docs/ | ||
- | # Examples will be in examples/ | + | # For example: gtk-4.6.1/ |
+ | |||
+ | # There are examples | ||
# Install to prefix (use `sudo` if doing system install) | # Install to prefix (use `sudo` if doing system install) | ||
Line 69: | Line 71: | ||
===== Documentation ===== | ===== Documentation ===== | ||
- | * Online API documentation: | ||
- | * Offline API documentation, | ||
- | * Example code is in the source code directory under '' | ||
+ | **Offline** | ||
+ | |||
+ | There is example code in the '' | ||
+ | |||
+ | * API documentation - '' | ||
+ | * Widget gallery: '' | ||
+ | * Example code: '' | ||
+ | |||
+ | **Online** | ||
+ | |||
+ | * API documentation: | ||
+ | * Widget gallery: [[https:// | ||
+ | * Example code: [[https:// | ||
===== Hello world ===== | ===== Hello world ===== | ||
Line 109: | Line 121: | ||
g_signal_connect (app, " | g_signal_connect (app, " | ||
return g_application_run (G_APPLICATION (app), argc, argv); | return g_application_run (G_APPLICATION (app), argc, argv); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== gtkmm (C++) ===== | ||
+ | |||
+ | You can use [[http:// | ||
+ | |||
+ | You might need some other dependencies like: | ||
+ | |||
+ | * sigc++-3.0 | ||
+ | * gtk4 | ||
+ | * glibmm-2.68 | ||
+ | * cairomm-1.16 | ||
+ | * pangomm-2.48 | ||
+ | |||
+ | |||
+ | To build from source: | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | # Install mm-common | ||
+ | sudo apt install mm-common | ||
+ | |||
+ | # Build and install libsigc++3 | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xzf libsigc++-3.2.0 | ||
+ | cd libsigc++-3.2.0 | ||
+ | cmake . | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # glibmm | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xzf glibmm-2.70.0.tar.gz | ||
+ | cd glibmm-2.70.0 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # cairomm | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xBf cairomm-1.16.1.tar.xz | ||
+ | cd cairomm-1.16.1 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | # pangomm | ||
+ | # https:// | ||
+ | wget https:// | ||
+ | tar xzf pangomm-2.50.0.tar.gz | ||
+ | cd pangomm-2.50.0 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | |||
+ | # gtkmm | ||
+ | wget https:// | ||
+ | tar xBf gtkmm-4.6.0.tar.xz | ||
+ | cd gtkmm-4.6.0 | ||
+ | ./ | ||
+ | make | ||
+ | sudo make install | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | When compiling, use '' | ||
+ | |||
+ | <code bash> | ||
+ | # Compile app with gtk4 | ||
+ | g++ main.cpp `pkg-config gtkmm-4.0 --cflags --libs` -std=c++20 | ||
+ | |||
+ | # Set path for shared library when running | ||
+ | LD_LIBRARY_PATH=/ | ||
+ | </ | ||
+ | |||
+ | Here is a gtkmm hello world: | ||
+ | |||
+ | <code cpp main.cpp> | ||
+ | // gtkmm4 example | ||
+ | |||
+ | // Compile with: | ||
+ | // g++ main.cpp `pkg-config gtkmm-4.0 --cflags --libs` -std=c++20 | ||
+ | |||
+ | // Run with | ||
+ | // LD_LIBRARY_PATH=/ | ||
+ | #include < | ||
+ | |||
+ | class MyWindow : public Gtk::Window | ||
+ | { | ||
+ | public: | ||
+ | MyWindow(); | ||
+ | }; | ||
+ | |||
+ | MyWindow:: | ||
+ | { | ||
+ | set_title(" | ||
+ | set_default_size(200, | ||
+ | } | ||
+ | |||
+ | int main(int argc, char* argv[]) | ||
+ | { | ||
+ | auto app = Gtk:: | ||
+ | |||
+ | return app-> | ||
} | } | ||
</ | </ |