Create example

This commit is contained in:
Matt McWilliams 2023-03-05 11:37:31 -05:00
commit 83be52c91a
6 changed files with 114 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
build

13
CMakeLists.txt Normal file
View File

@ -0,0 +1,13 @@
PROJECT ( example )
cmake_minimum_required( VERSION 3.22 )
FIND_PACKAGE ( PkgConfig REQUIRED )
PKG_CHECK_MODULES( GTK REQUIRED gtkmm-4.0)
INCLUDE_DIRECTORIES ( ${GTK_INCLUDE_DIRS} )
ADD_EXECUTABLE ( example main.cpp )
TARGET_LINK_LIBRARIES( example ${CMAKE_THREAD_LIBS_INIT} ${GTK_LIBRARIES} )

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# GTK Example
### Ubuntu
```bash
sudo apt install libgtkmm-2.4-dev
```

8
compile.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
#g++ main.cpp $(pkg-config gtkmm-4.0 --cflags --libs)
mkdir -p build
cd build
cmake ..
make

69
install.sh Normal file
View File

@ -0,0 +1,69 @@
#!/bin/bash
set -e
# https://terminalroot.com/how-to-install-gtkmm-4-on-ubuntu-2204/
# https://www.devdungeon.com/wiki/doku.php?id=programming:gtk4
#sudo apt install build-essential git g++ autotools-dev libgtkmm-3.0-dev \
# libgtkmm-3.0-doc mm-common libgtk-4-bin \
# libgtk-4-common libgtk-4-dev libgtk-4-doc pkg-config
if [ ! -f libsigc++-3.0.7.tar.xz ]; then
wget https://download.gnome.org/sources/libsigc++/3.0/libsigc++-3.0.7.tar.xz
fi
tar Jxvf libsigc++-3.0.7.tar.xz
cd libsigc++-3.0.7/
./autogen.sh --prefix=/usr/local
make -j`nproc --ignore=2`
sudo make install
if [ ! -f glibmm-2.68.2.tar.xz ]; then
wget https://download.gnome.org/sources/glibmm/2.68/glibmm-2.68.2.tar.xz
fi
tar Jxvf glibmm-2.68.2.tar.xz
cd glibmm-2.68.2/
./autogen.sh --prefix=/usr
make -j`nproc --ignore=2`
sudo make install
cd ..
if [ ! -d cairomm ]; then
git clone https://github.com/freedesktop/cairomm.git
fi
cd cairomm
./autogen.sh --prefix=/usr
make -j`nproc --ignore=2`
sudo make install
cd ..
if [ ! -f pangomm-2.50.0.tar.xz ]; then
wget https://download.gnome.org/sources/pangomm/2.50/pangomm-2.50.0.tar.xz
fi
tar Jxvf pangomm-2.50.0.tar.xz
cd pangomm-2.50.0/
./autogen.sh --prefix=/usr
make -j`nproc --ignore=2`
sudo make install
cd ..
ls /usr/lib/libsigc-3*
sudo ln -s /usr/local/lib/libsigc-3.0.so.0.0.0 /usr/lib/libsigc-3.0.so.0.0.0
sudo ln -s /usr/local/lib/libsigc-3.0.la /usr/lib/libsigc-3.0.la
sudo ln -s /usr/local/lib/libsigc-3.0.so /usr/lib/libsigc-3.0.so
sudo ln -s /usr/local/lib/libsigc-3.0.so.0 /usr/lib/libsigc-3.0.so.0
if [ ! -f gtkmm-4.6.1.tar.xz ]; then
wget https://download.gnome.org/sources/gtkmm/4.6/gtkmm-4.6.1.tar.xz
wget https://download.gnome.org/sources/gtkmm/4.6/gtkmm-4.6.1.sha256sum
sha256sum -c --ignore-missing gtkmm-4.6.1.sha256sum
fi
tar Jxvf gtkmm-4.6.1.tar.xz
cd gtkmm-4.6.1
./autogen.sh --prefix=/usr
make -j`nproc --ignore=2`
sudo make install

16
main.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <gtkmm.h>
class GTKExample : public Gtk::Window {
public:
GTKExample();
};
GTKExample::GTKExample(){
set_title("GTK Example");
set_default_size(800, 450);
}
int main(int argc, char ** argv){
auto app = Gtk::Application::create("com.example.gtk");
return app->make_window_and_run<GTKExample>(argc, argv);
}