From 01893c600dcab10d997afe5fa65f9737ddb18d63 Mon Sep 17 00:00:00 2001 From: daleclack Date: Fri, 17 Mar 2023 18:08:15 +0800 Subject: [PATCH] Add gtk147 --- Gtk4/gtk147_file_exp2/.vscode/settings.json | 3 + Gtk4/gtk147_file_exp2/CMakeLists.txt | 61 +++++++++++++++++++++ Gtk4/gtk147_file_exp2/src/FileManager.cpp | 19 +++++++ Gtk4/gtk147_file_exp2/src/FileManager.h | 7 +++ Gtk4/gtk147_file_exp2/src/main.cpp | 20 +++++++ Gtkmm4/gtk146_gtkui6_a3/src/MainWin.cc | 4 +- 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 Gtk4/gtk147_file_exp2/.vscode/settings.json create mode 100644 Gtk4/gtk147_file_exp2/CMakeLists.txt create mode 100644 Gtk4/gtk147_file_exp2/src/FileManager.cpp create mode 100644 Gtk4/gtk147_file_exp2/src/FileManager.h create mode 100644 Gtk4/gtk147_file_exp2/src/main.cpp diff --git a/Gtk4/gtk147_file_exp2/.vscode/settings.json b/Gtk4/gtk147_file_exp2/.vscode/settings.json new file mode 100644 index 0000000..b4d8c35 --- /dev/null +++ b/Gtk4/gtk147_file_exp2/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools" +} \ No newline at end of file diff --git a/Gtk4/gtk147_file_exp2/CMakeLists.txt b/Gtk4/gtk147_file_exp2/CMakeLists.txt new file mode 100644 index 0000000..d674787 --- /dev/null +++ b/Gtk4/gtk147_file_exp2/CMakeLists.txt @@ -0,0 +1,61 @@ +set(CMAKE_CXX_STANDARD 17) +cmake_minimum_required(VERSION 3.0.0) +project(gtk147 VERSION 1.0.0) + +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../GCR_CMake/macros) +include(GlibCompileResourcesSupport) + +include(CTest) +enable_testing() + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) + +include(CPack) +include_directories(.) +include_directories(..) + +find_package (PkgConfig REQUIRED) +pkg_check_modules (GTK4 REQUIRED gtk4) +include_directories (${GTK4_INCLUDE_DIRS}) +link_directories (${GTK4_LIBRARY_DIRS}) + +#Compile Resource +#[[ +set(RESOURCE_LIST + Yanni-Nightingale.mp3) + +compile_gresources(RESOURCE_FILE + XML_OUT + TYPE EMBED_C + RESOURCES ${RESOURCE_LIST} + PREFIX "/org/gtk/daleclack" + SOURCE_DIR ${PROJECT_SOURCE_DIR}/res) + +# Add a custom target to the makefile. Now make builds our resource file. +# It depends on the output RESOURCE_FILE. +add_custom_target(resource ALL DEPENDS ${RESOURCE_FILE})]] + +#SOURCE FILES LIST +set(SOURCES src/main.cpp src/FileManager.cpp) + +#For win32 platform,use rc resource and .ico icon +if(WIN32) + SET(CMAKE_RC_COMPILER windres) + set(app_WINRC ../icon.rc) + set_property(SOURCE ../icon.rc APPEND PROPERTY + OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/../icon.ico + ) + add_executable(${PROJECT_NAME} WIN32 ${app_WINRC} ${SOURCES}) +else() + add_executable(${PROJECT_NAME} ${SOURCES}) + +endif(WIN32) + +#Add command to generate .gitignore +add_custom_command(TARGET ${PROJECT_NAME} + COMMAND echo \"*\" > ${CMAKE_BINARY_DIR}/.gitignore + COMMAND echo \"**/*\" > ${CMAKE_BINARY_DIR}/.hgignore) + +SET (CMAKE_EXTRA_CXX_FLAGS ${GTK4_CFLAGS_OTHER}) +target_link_libraries (${PROJECT_NAME} ${GTK4_LIBRARIES} -lpthread) diff --git a/Gtk4/gtk147_file_exp2/src/FileManager.cpp b/Gtk4/gtk147_file_exp2/src/FileManager.cpp new file mode 100644 index 0000000..fad103a --- /dev/null +++ b/Gtk4/gtk147_file_exp2/src/FileManager.cpp @@ -0,0 +1,19 @@ +#include "FileManager.h" + +struct _FileManager{ + GtkWindow parent_instance; +}; + +G_DEFINE_TYPE(FileManager, file_manager, GTK_TYPE_WINDOW) + +static void file_manager_init(FileManager *self){ + +} + +static void file_manager_class_init(FileManagerClass *klass){ + +} + +FileManager *file_manager_new(){ + return FILE_MANAGER(g_object_new(file_manager_get_type(), NULL)); +} diff --git a/Gtk4/gtk147_file_exp2/src/FileManager.h b/Gtk4/gtk147_file_exp2/src/FileManager.h new file mode 100644 index 0000000..ce801fd --- /dev/null +++ b/Gtk4/gtk147_file_exp2/src/FileManager.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +G_DECLARE_FINAL_TYPE(FileManager, file_manager, FILE, MANAGER, GtkWindow) + +FileManager *file_manager_new(); diff --git a/Gtk4/gtk147_file_exp2/src/main.cpp b/Gtk4/gtk147_file_exp2/src/main.cpp new file mode 100644 index 0000000..0332022 --- /dev/null +++ b/Gtk4/gtk147_file_exp2/src/main.cpp @@ -0,0 +1,20 @@ +#include "FileManager.h" + +static void gtkmain(GtkApplication *app, gpointer user_data){ + // Create a main window + FileManager *file_win = file_manager_new(); + + // Add the window to the application + gtk_application_add_window(app, GTK_WINDOW(file_win)); + + // Show the window + gtk_window_present(GTK_WINDOW(file_win)); +} + +int main(int argc, char **argv) +{ + // Create a application and run + GtkApplication *app = gtk_application_new("org.gtk.daleclack", G_APPLICATION_NON_UNIQUE); + g_signal_connect(app, "activate", G_CALLBACK(gtkmain), NULL); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/Gtkmm4/gtk146_gtkui6_a3/src/MainWin.cc b/Gtkmm4/gtk146_gtkui6_a3/src/MainWin.cc index ca6c86a..c77c74d 100644 --- a/Gtkmm4/gtk146_gtkui6_a3/src/MainWin.cc +++ b/Gtkmm4/gtk146_gtkui6_a3/src/MainWin.cc @@ -59,8 +59,10 @@ MainWin::MainWin() label1.set_valign(Gtk::Align::FILL); main_box.append(label1); - // Add buttons] + // Background color for btn_box btn_box.add_css_class("accdoration"); + + // Add buttons btn_main.set_has_frame(false); btn_win1.set_has_frame(false); btn_win2.set_has_frame(false);