diff --git a/Makefile b/Makefile index afc642e..4d3ba20 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC=g++ -CFLAGS= -c -g -Wall -LDLIBS = -lgtk +CFLAGS= -c -g -Wall $(shell pkg-config --cflags gtkmm-4.0) +LDLIBS = $(shell pkg-config --libs gtkmm-4.0) TARGET := untap @@ -15,7 +15,7 @@ OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) $(BUILD_DIR)/$(TARGET): $(OBJS) $(CC) $(OBJS) -o $@ $(LDLIBS) -$(BUILD_DIR)/%.c.o: %.cpp +$(BUILD_DIR)/%.cpp.o: %.cpp mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ diff --git a/build/src/helloworld.cpp.o b/build/src/helloworld.cpp.o new file mode 100644 index 0000000..d9f6cb6 Binary files /dev/null and b/build/src/helloworld.cpp.o differ diff --git a/build/src/main.cpp.o b/build/src/main.cpp.o new file mode 100644 index 0000000..906a82c Binary files /dev/null and b/build/src/main.cpp.o differ diff --git a/build/untap b/build/untap new file mode 100755 index 0000000..a57e87a Binary files /dev/null and b/build/untap differ diff --git a/src/helloworld.cpp b/src/helloworld.cpp new file mode 100644 index 0000000..39afb9b --- /dev/null +++ b/src/helloworld.cpp @@ -0,0 +1,24 @@ +#include "include/helloworld.h" + +#include + +HelloWorld::HelloWorld() + : m_button("Hello world!") +{ + m_button.set_margin(10); + + m_button.signal_clicked().connect(sigc::mem_fun(*this, + &HelloWorld::on_button_clicked)); + + set_child(m_button); +} + +HelloWorld::~HelloWorld() +{ + +} + +void HelloWorld::on_button_clicked() +{ + std::cout << "Hello, World!" << std::endl; +} diff --git a/src/include/helloworld.h b/src/include/helloworld.h new file mode 100644 index 0000000..902b6d2 --- /dev/null +++ b/src/include/helloworld.h @@ -0,0 +1,19 @@ +#ifndef GTKMM_EXAMPLE_HELLOWORLD_H +#define GTKMM_EXAMPLE_HELLOWORLD_H + +#include +#include + +class HelloWorld : public Gtk::Window +{ + public: + HelloWorld(); + ~HelloWorld() override; + + protected: + void on_button_clicked(); + + Gtk::Button m_button; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index e69de29..139053e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -0,0 +1,10 @@ +#include "include/helloworld.h" + +#include + +int main(int argc, char* argv[]) +{ + auto app = Gtk::Application::create("org.gtkmm.example"); + + return app->make_window_and_run(argc, argv); +}