hello, world!

This commit is contained in:
Nathan Singer 2025-04-21 21:33:50 -04:00
parent bf9bce08a8
commit 59e838aabb
7 changed files with 56 additions and 3 deletions

View File

@ -1,7 +1,7 @@
CC=g++ 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 TARGET := untap
@ -15,7 +15,7 @@ OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
$(BUILD_DIR)/$(TARGET): $(OBJS) $(BUILD_DIR)/$(TARGET): $(OBJS)
$(CC) $(OBJS) -o $@ $(LDLIBS) $(CC) $(OBJS) -o $@ $(LDLIBS)
$(BUILD_DIR)/%.c.o: %.cpp $(BUILD_DIR)/%.cpp.o: %.cpp
mkdir -p $(dir $@) mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@

BIN
build/src/helloworld.cpp.o Normal file

Binary file not shown.

BIN
build/src/main.cpp.o Normal file

Binary file not shown.

BIN
build/untap Executable file

Binary file not shown.

24
src/helloworld.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "include/helloworld.h"
#include <iostream>
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;
}

19
src/include/helloworld.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
#define GTKMM_EXAMPLE_HELLOWORLD_H
#include <gtkmm/button.h>
#include <gtkmm/window.h>
class HelloWorld : public Gtk::Window
{
public:
HelloWorld();
~HelloWorld() override;
protected:
void on_button_clicked();
Gtk::Button m_button;
};
#endif

View File

@ -0,0 +1,10 @@
#include "include/helloworld.h"
#include <gtkmm/application.h>
int main(int argc, char* argv[])
{
auto app = Gtk::Application::create("org.gtkmm.example");
return app->make_window_and_run<HelloWorld>(argc, argv);
}