Compare commits
	
		
			No commits in common. "124f15c213ef1ed15111f168ad0e9935fec0f4dd" and "ee19b389b06353b956308fdb195728e842f4e213" have entirely different histories.
		
	
	
		
			
				124f15c213
			
			...
			
				ee19b389b0
			
		
	
		
					 6 changed files with 15 additions and 95 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitmodules
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1,6 +1,3 @@
 | 
			
		|||
[submodule "external/assimp"]
 | 
			
		||||
	path = external/assimp
 | 
			
		||||
	url = https://github.com/assimp/assimp.git
 | 
			
		||||
[submodule "external/spdlog"]
 | 
			
		||||
	path = external/spdlog
 | 
			
		||||
	url = https://github.com/gabime/spdlog.git
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,14 +60,6 @@ else ()
 | 
			
		|||
endif ()
 | 
			
		||||
add_subdirectory(external/assimp EXCLUDE_FROM_ALL)
 | 
			
		||||
 | 
			
		||||
option(SPDLOG_ENABLE_PCH "Build static or shared library using precompiled header to speed up compilation time" ON)
 | 
			
		||||
option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" ON)
 | 
			
		||||
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" ON)
 | 
			
		||||
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" ON)
 | 
			
		||||
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" ON)
 | 
			
		||||
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" ON)
 | 
			
		||||
add_subdirectory(external/spdlog EXCLUDE_FROM_ALL)
 | 
			
		||||
 | 
			
		||||
add_executable(LearnGtk4 main.cpp
 | 
			
		||||
        hello_world.cpp
 | 
			
		||||
        hello_world.hpp
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +67,7 @@ add_executable(LearnGtk4 main.cpp
 | 
			
		|||
        app_win_2_back.hpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
set_target_properties(LearnGtk4 assimp spdlog_header_only PROPERTIES
 | 
			
		||||
set_target_properties(LearnGtk4 assimp PROPERTIES
 | 
			
		||||
        CXX_STANDARD 17
 | 
			
		||||
        CXX_STANDARD_REQUIRED ON
 | 
			
		||||
        CXX_EXTENSIONS OFF
 | 
			
		||||
| 
						 | 
				
			
			@ -86,4 +78,4 @@ target_compile_definitions(LearnGtk4 PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
 | 
			
		|||
target_compile_definitions(assimp PUBLIC $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
 | 
			
		||||
target_compile_options(LearnGtk4 PUBLIC ${COMPILE_FLAGS})
 | 
			
		||||
target_link_options(LearnGtk4 PUBLIC ${LINKER_OPTIONS})
 | 
			
		||||
target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 assimp spdlog_header_only)
 | 
			
		||||
target_link_libraries(LearnGtk4 PkgConfig::GTKMM4 assimp)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,7 @@
 | 
			
		|||
#include "app_win_2_back.hpp"
 | 
			
		||||
#include "hello_world.hpp"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <glibmm/miscutils.h>
 | 
			
		||||
#include <gtkmm/switch.h>
 | 
			
		||||
#include <spdlog/spdlog.h>
 | 
			
		||||
 | 
			
		||||
namespace gui_to_app {
 | 
			
		||||
    AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
 | 
			
		||||
| 
						 | 
				
			
			@ -16,12 +15,12 @@ namespace gui_to_app {
 | 
			
		|||
                const auto builder = Gtk::Builder::create_from_file("menu_bar.ui");
 | 
			
		||||
                return builder->get_object<Gio::Menu>("menu");
 | 
			
		||||
            } catch (const std::exception &e) {
 | 
			
		||||
                spdlog::error("Error occurred while loader menu bar: {}", e.what());
 | 
			
		||||
                std::cerr << e.what() << '\n';
 | 
			
		||||
                return nullptr;
 | 
			
		||||
            }
 | 
			
		||||
        }();
 | 
			
		||||
        if (!menu_bar) {
 | 
			
		||||
            spdlog::error("Error occured while loading menu bar's.");
 | 
			
		||||
            std::cerr << "Error occured while loading menu bar's.\n";
 | 
			
		||||
        } else {
 | 
			
		||||
            set_menubar(menu_bar);
 | 
			
		||||
            add_action("quit", sigc::mem_fun(*this, &AppWin2Back::on_quit));
 | 
			
		||||
| 
						 | 
				
			
			@ -36,17 +35,17 @@ namespace gui_to_app {
 | 
			
		|||
    void AppWin2Back::on_activate() {
 | 
			
		||||
        Application::on_activate();
 | 
			
		||||
 | 
			
		||||
        app_builder = [this]() -> Glib::RefPtr<Gtk::Builder> {
 | 
			
		||||
        const auto app_builder = [this]() -> Glib::RefPtr<Gtk::Builder> {
 | 
			
		||||
            try {
 | 
			
		||||
                return Gtk::Builder::create_from_file("window_ui.ui");
 | 
			
		||||
            } catch (const std::exception &e) {
 | 
			
		||||
                spdlog::critical("Error occurred while loading Window's UI: {}", e.what());
 | 
			
		||||
                std::cerr << e.what() << std::endl;
 | 
			
		||||
                quit();
 | 
			
		||||
                return nullptr;
 | 
			
		||||
            }
 | 
			
		||||
        }();
 | 
			
		||||
        if (!app_builder) {
 | 
			
		||||
            spdlog::critical("Error while loading UI");
 | 
			
		||||
            std::cerr << "Error while loading UI.\n";
 | 
			
		||||
            quit();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -56,65 +55,16 @@ namespace gui_to_app {
 | 
			
		|||
            main_window->set_show_menubar(true);
 | 
			
		||||
            main_window->set_visible(true);
 | 
			
		||||
        } else {
 | 
			
		||||
            spdlog::critical("Error while getting window from builder");
 | 
			
		||||
            on_quit();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        sword_switch = app_builder->get_widget<Gtk::Switch>("sword_switch");
 | 
			
		||||
        lance_switch = app_builder->get_widget<Gtk::Switch>("lance_switch");
 | 
			
		||||
        morgen_switch = app_builder->get_widget<Gtk::Switch>("morgenstern_switch");
 | 
			
		||||
        bow_switch = app_builder->get_widget<Gtk::Switch>("arc_switch");
 | 
			
		||||
        chainmail_switch = app_builder->get_widget<Gtk::Switch>("chainmail_switch");
 | 
			
		||||
        cookpot_switch = app_builder->get_widget<Gtk::Switch>("cookingpot_switch");
 | 
			
		||||
        pamphlet_switch = app_builder->get_widget<Gtk::Switch>("pamphlet_tourist_switch");
 | 
			
		||||
        medkit_switch = app_builder->get_widget<Gtk::Switch>("medkit_switch");
 | 
			
		||||
        fourche_switch = app_builder->get_widget<Gtk::Switch>("fourche_switch");
 | 
			
		||||
        dagger_switch = app_builder->get_widget<Gtk::Switch>("dagger_switch");
 | 
			
		||||
        rock_kit_switch = app_builder->get_widget<Gtk::Switch>("rock_kit_switch");
 | 
			
		||||
        sack_switch = app_builder->get_widget<Gtk::Switch>("sack_switch");
 | 
			
		||||
 | 
			
		||||
        const auto test_result = [this]() -> std::vector<const char *> {
 | 
			
		||||
            const std::array test_ptrs{
 | 
			
		||||
                std::pair{ "sword_switch", sword_switch == nullptr },
 | 
			
		||||
                std::pair{ "lance_switch", lance_switch == nullptr },
 | 
			
		||||
                std::pair{ "morgen_switch", morgen_switch == nullptr },
 | 
			
		||||
                std::pair{ "bow_switch", bow_switch == nullptr },
 | 
			
		||||
                std::pair{ "chainmail_switch", chainmail_switch == nullptr },
 | 
			
		||||
                std::pair{ "cookpot_switch", cookpot_switch == nullptr },
 | 
			
		||||
                std::pair{ "pamphlet_switch", pamphlet_switch == nullptr },
 | 
			
		||||
                std::pair{ "medkit_switch", medkit_switch == nullptr },
 | 
			
		||||
                std::pair{ "fourche_switch", fourche_switch == nullptr },
 | 
			
		||||
                std::pair{ "dagger_switch", dagger_switch == nullptr },
 | 
			
		||||
                std::pair{ "rock_kit_switch", rock_kit_switch == nullptr },
 | 
			
		||||
                std::pair{ "sack_switch", sack_switch == nullptr },
 | 
			
		||||
            };
 | 
			
		||||
            std::vector<const char *> local_test_result;
 | 
			
		||||
            local_test_result.reserve(test_ptrs.size());
 | 
			
		||||
            std::for_each(test_ptrs.cbegin(),
 | 
			
		||||
                test_ptrs.cend(),
 | 
			
		||||
                [&local_test_result](const auto &a) {
 | 
			
		||||
                    if (a.second) {
 | 
			
		||||
                        local_test_result.emplace_back(a.first);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            return local_test_result;
 | 
			
		||||
        }();
 | 
			
		||||
        if (!test_result.empty()) {
 | 
			
		||||
            spdlog::critical("Error occurred, at least one switch is not available. See logs below");
 | 
			
		||||
            for (const auto result: test_result) {
 | 
			
		||||
                spdlog::critical(result);
 | 
			
		||||
            }
 | 
			
		||||
            on_quit();
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void AppWin2Back::on_quit() noexcept {
 | 
			
		||||
    void AppWin2Back::on_quit() {
 | 
			
		||||
        auto windows = get_windows();
 | 
			
		||||
        for (auto *window: windows) {
 | 
			
		||||
            window->set_visible(false);
 | 
			
		||||
            delete window;
 | 
			
		||||
        }
 | 
			
		||||
        quit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
} // gui_to_app
 | 
			
		||||
| 
						 | 
				
			
			@ -8,12 +8,8 @@ namespace learn_gtkmm4 {
 | 
			
		|||
    class HelloWorld;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace Gtk {
 | 
			
		||||
    class Builder;
 | 
			
		||||
    class Switch;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
namespace gui_to_app {
 | 
			
		||||
 | 
			
		||||
    class AppWin2Back final : public Gtk::Application {
 | 
			
		||||
    public:
 | 
			
		||||
        ~AppWin2Back() noexcept final = default;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,25 +24,11 @@ namespace gui_to_app {
 | 
			
		|||
        void on_activate() final;
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        void on_quit() noexcept;
 | 
			
		||||
        void on_quit();
 | 
			
		||||
 | 
			
		||||
        Glib::RefPtr<Gtk::Builder> app_builder;
 | 
			
		||||
        learn_gtkmm4::HelloWorld *main_window{ nullptr };
 | 
			
		||||
        Gtk::Switch *sword_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *lance_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *morgen_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *bow_switch{ nullptr };
 | 
			
		||||
 | 
			
		||||
        Gtk::Switch *chainmail_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *cookpot_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *pamphlet_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *medkit_switch{ nullptr };
 | 
			
		||||
 | 
			
		||||
        Gtk::Switch *fourche_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *dagger_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *rock_kit_switch{ nullptr };
 | 
			
		||||
        Gtk::Switch *sack_switch{ nullptr };
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
} // gui_to_app
 | 
			
		||||
 | 
			
		||||
#endif //LEARNGTK4_APP_WIN_2_BACK_HPP
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								external/spdlog
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								external/spdlog
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
Subproject commit 27cb4c76708608465c413f6d0e6b8d99a4d84302
 | 
			
		||||
| 
						 | 
				
			
			@ -343,7 +343,7 @@
 | 
			
		|||
                                  </object>
 | 
			
		||||
                                </child>
 | 
			
		||||
                                <child>
 | 
			
		||||
                                  <object class="GtkSwitch" id="chainmail_switch">
 | 
			
		||||
                                  <object class="GtkSwitch" id="chaimail_switch">
 | 
			
		||||
                                    <property name="halign">end</property>
 | 
			
		||||
                                    <property name="hexpand">1</property>
 | 
			
		||||
                                  </object>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue