diff --git a/Gtkmm3/gtk83_timer2/.vscode/c_cpp_properties.json b/Gtkmm3/gtk83_timer2/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..1e4207f --- /dev/null +++ b/Gtkmm3/gtk83_timer2/.vscode/c_cpp_properties.json @@ -0,0 +1,193 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + //For linux amd64 and linux on arm64,some include path may different + //Commet and uncomment these lines to compile on a specificed archtiecture + //Arm64 linux libs + /* + "/usr/lib/aarch64-linux-gnu/dbus-1.0/include/**", + "/usr/lib/aarch64-linux-gnu/glib-2.0/include/**", + "/usr/lib/aarch64-linux-gnu/gtkmm-3.0/include/**", + "/usr/lib/aarch64-linux-gnu/gdkmm-3.0/include/**", + "/usr/lib/aarch64-linux-gnu/giomm-2.4/include/**", + "/usr/lib/aarch64-linux-gnu/pangomm-1.4/include/**", + "/usr/lib/aarch64-linux-gnu/glibmm-2.4/include/**", + "/usr/lib/aarch64-linux-gnu/cairomm-1.0/include/**", + "/usr/lib/aarch64-linux-gnu/sigc++-2.0/include/**", + */ + //amd64 linux libs(For ubuntu) + /* + "/usr/lib/x86_64-linux-gnu/dbus-1.0/include/**", + "/usr/lib/x86_64-linux-gnu/glib-2.0/include/**", + "/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include/**", + "/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include/**", + "/usr/lib/x86_64-linux-gnu/giomm-2.4/include/**", + "/usr/lib/x86_64-linux-gnu/pangomm-1.4/include/**", + "/usr/lib/x86_64-linux-gnu/glibmm-2.4/include/**", + "/usr/lib/x86_64-linux-gnu/cairomm-1.0/include/**", + "/usr/lib/x86_64-linux-gnu/sigc++-2.0/include/**", + */ + //For debian and ubuntu,kali + /* + "/usr/include/gtk-3.0/gtk/**", + "/usr/include/uuid/**", + */ + //For manjaro(Arch linux) + "/usr/lib/dbus-1.0/include/**", + "/usr/lib/glib-2.0/include/**", + "/usr/include/lzo/**", + "/usr/include/cloudproviders/**", + "${workspaceFolder}/**", + "${workspaceFolder}/../**", + "/usr/include/gtk-3.0/**", + "/usr/include/at-spi2-atk/2.0/**", + "/usr/include/at-spi-2.0/**", + "/usr/include/dbus-1.0/**", + "/usr/include/gio-unix-2.0/**", + "/usr/include/cairo/**", + "/usr/include/pango-1.0/**", + "/usr/include/fribidi/**", + "/usr/include/harfbuzz/**", + "/usr/include/atk-1.0/**", + "/usr/include/pixman-1/**", + "/usr/include/freetype2/**", + "/usr/include/libpng16/**", + "/usr/include/gdk-pixbuf-2.0/**", + "/usr/include/libmount/**", + "/usr/include/blkid/**", + "/usr/include/glib-2.0/**", + //Gtkmm libs + "/usr/include/gtkmm-3.0/**", + "/usr/lib/gtkmm-3.0/include/**", + "/usr/include/giomm-2.4/**", + "/usr/lib/giomm-2.4/include/**", + "/usr/include/glibmm-2.4/**", + "/usr/lib/glibmm-2.4/include/**", + "/usr/include/sigc++-2.0/**", + "/usr/lib/sigc++-2.0/include/**", + "/usr/include/cairomm-1.0/**", + "/usr/lib/cairomm-1.0/include/**", + "/usr/include/pangomm-1.4/**", + "/usr/lib/pangomm-1.4/include/**", + "/usr/include/atkmm-1.6/**", + "/usr/lib/atkmm-1.6/include/**", + "/usr/include/gtk-3.0/unix-print/**", + "/usr/include/gdkmm-3.0/**", + "/usr/lib/gdkmm-3.0/include/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "gcc-x64", + "compilerArgs": [ + "`pkg-config --cflags --libs gtkmm-3.0`" + ], + "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "win32", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/src/**", + //I assume the msys2 installed in D:/msys64 + "D:/msys64/mingw64/include/gtkmm-3.0/**", + "D:/msys64/mingw64/lib/gtkmm-3.0/include/**", + "D:/msys64/mingw64/include/giomm-2.4/**", + "D:/msys64/mingw64/lib/giomm-2.4/include/**", + "D:/msys64/mingw64/include/**", + "D:/msys64/mingw64/include/glib-2.0/**", + "D:/msys64/mingw64/lib/glib-2.0/include/**", + "D:/msys64/mingw64/include/glibmm-2.4/**", + "D:/msys64/mingw64/lib/glibmm-2.4/include/**", + "D:/msys64/mingw64/include/sigc++-2.0/**", + "D:/msys64/mingw64/lib/sigc++-2.0/include/**", + "D:/msys64/mingw64/include/gtk-3.0/**", + "D:/msys64/mingw64/include/pango-1.0/**", + "D:/msys64/mingw64/include/harfbuzz/**", + "D:/msys64/mingw64/include/freetype2/**", + "D:/msys64/mingw64/include/libpng16/**", + "D:/msys64/mingw64/include/fribidi/**", + "D:/msys64/mingw64/include/cairo/**", + "D:/msys64/mingw64/include/lzo/**", + "D:/msys64/mingw64/include/pixman-1/**", + "D:/msys64/mingw64/include/gdk-pixbuf-2.0", + "D:/msys64/mingw64/include/atk-1.0", + "D:/msys64/mingw64/include/cairomm-1.0/**", + "D:/msys64/mingw64/lib/cairomm-1.0/include/**", + "D:/msys64/mingw64/include/pangomm-1.4/**", + "D:/msys64/mingw64/lib/pangomm-1.4/include/**" + ], + "defines": [], + "compilerPath": "D:/msys64/MinGW64/bin/gcc.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-gcc-x64" + }, + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**", + "/usr/local/Cellar/libffi/3.3_3/include/**", + "/usr/local/Cellar/gtkmm3/3.24.4/include/gtkmm-3.0/**", + "/usr/local/Cellar/gtkmm3/3.24.4/lib/gtkmm-3.0/include", + "/usr/local/Cellar/atkmm@2.28/2.28.1_1/include/atkmm-1.6/**", + "/usr/local/Cellar/atkmm@2.28/2.28.1_1/lib/atkmm-1.6/include/**", + "/usr/local/Cellar/gtk+3/3.24.29/include/gtk-3.0/unix-print/**", + "/usr/local/Cellar/gtkmm3/3.24.4/include/gdkmm-3.0/**", + "/usr/local/Cellar/gtkmm3/3.24.4/lib/gdkmm-3.0/include/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/include/giomm-2.4/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/lib/giomm-2.4/include/**", + "/usr/local/Cellar/pangomm@2.46/2.46.0/include/pangomm-1.4/**", + "/usr/local/Cellar/pangomm@2.46/2.46.0/lib/pangomm-1.4/include/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/include/glibmm-2.4/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/lib/glibmm-2.4/include/**", + "/usr/local/Cellar/cairomm@1.14/1.14.2/include/cairomm-1.0/**", + "/usr/local/Cellar/cairomm@1.14/1.14.2/lib/cairomm-1.0/include/**", + "/usr/local/Cellar/libsigc++@2/2.10.6/include/sigc++-2.0/**", + "/usr/local/Cellar/libsigc++@2/2.10.6/lib/sigc++-2.0/include/**", + "/usr/local/Cellar/gtk+3/3.24.29/include/gtk-3.0/**", + "/usr/local/Cellar/glib/2.68.2/include/gio-unix-2.0/**", + "/usr/local/Cellar/cairo/1.16.0_5/include/cairo/**", + "/usr/local/Cellar/libepoxy/1.5.7/include/**", + "/usr/local/Cellar/pango/1.48.4/include/pango-1.0", + "/usr/local/Cellar/harfbuzz/2.8.1/include/harfbuzz", + "/usr/local/Cellar/pango/1.48.4/include/pango-1.0/**", + "/usr/local/Cellar/fribidi/1.0.10/include/fribidi/**", + "/usr/local/Cellar/harfbuzz/2.8.1/include/harfbuzz/**", + "/usr/local/Cellar/graphite2/1.3.14/include/**", + "/usr/local/Cellar/atk/2.36.0/include/atk-1.0/**", + "/usr/local/Cellar/cairo/1.16.0_5/include/cairo/**", + "/usr/local/Cellar/pixman/0.40.0/include/pixman-1/**", + "/usr/local/Cellar/fontconfig/2.13.1/include/**", + "/usr/local/opt/freetype/include/freetype2/**", + "/usr/local/Cellar/libpng/1.6.37/include/libpng16/**", + "/usr/local/Cellar/libxcb/1.14_1/include/**", + "/usr/local/Cellar/libxrender/0.9.10/include/**", + "/usr/local/Cellar/libxext/1.3.4/include/**", + "/usr/local/Cellar/libx11/1.7.0/include/**", + "/usr/local/Cellar/libxcb/1.14_1/include/**", + "/usr/local/Cellar/libxau/1.0.9/include/**", + "/usr/local/Cellar/libxdmcp/1.1.3/include/**", + "/usr/local/Cellar/gdk-pixbuf/2.42.6/include/gdk-pixbuf-2.0/**", + "/usr/local/Cellar/libpng/1.6.37/include/libpng16/**", + "/usr/local/Cellar/libtiff/4.3.0/include/**", + "/usr/local/Cellar/glib/2.68.2/include/**", + "/usr/local/Cellar/glib/2.68.2/include/glib-2.0/**", + "/usr/local/Cellar/glib/2.68.2/lib/glib-2.0/include/**", + "/usr/local/opt/gettext/include/**", + "/usr/local/Cellar/pcre/8.44/include/**", + "/usr/local/Cellar/xorgproto/2021.4/include/**" + ], + "defines": [], + "macFrameworkPath": [], + "compilerPath": "/usr/local/bin/gcc-11", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "macos-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Gtkmm3/gtk83_timer2/.vscode/settings.json b/Gtkmm3/gtk83_timer2/.vscode/settings.json new file mode 100644 index 0000000..208afcc --- /dev/null +++ b/Gtkmm3/gtk83_timer2/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "C_Cpp.errorSquiggles": "Disabled", + "cmake.configureOnOpen": false, + "C_Cpp.dimInactiveRegions": false +} \ No newline at end of file diff --git a/Gtkmm3/gtk83_timer2/CMakeLists.txt b/Gtkmm3/gtk83_timer2/CMakeLists.txt new file mode 100644 index 0000000..150fd35 --- /dev/null +++ b/Gtkmm3/gtk83_timer2/CMakeLists.txt @@ -0,0 +1,19 @@ +set(CMAKE_CXX_STANDARD 17) +cmake_minimum_required(VERSION 3.0.0) +project(gtk83 VERSION 0.1.0) + +include(CTest) +enable_testing() + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) + +include(CPack) + +find_package (PkgConfig REQUIRED) +pkg_check_modules (GTKMM3 REQUIRED gtkmm-3.0) +include_directories (${GTKMM3_INCLUDE_DIRS}) +link_directories (${GTKMM3_LIBRARY_DIRS}) +add_executable(gtk83 src/main.cc src/MyApp.cc) +add_definitions (${GTKMM3_CFLAGS_OTHER}) +target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES}) diff --git a/Gtkmm3/gtk83_timer2/build_mingw.cmd b/Gtkmm3/gtk83_timer2/build_mingw.cmd new file mode 100644 index 0000000..4b8be51 --- /dev/null +++ b/Gtkmm3/gtk83_timer2/build_mingw.cmd @@ -0,0 +1,3 @@ +cd build_mingw +mingw32-make +gtk83 diff --git a/Gtkmm3/gtk83_timer2/res/window.ui b/Gtkmm3/gtk83_timer2/res/window.ui new file mode 100644 index 0000000..7b93db1 --- /dev/null +++ b/Gtkmm3/gtk83_timer2/res/window.ui @@ -0,0 +1,141 @@ + + + + + + False + org.gtk.daleclack + + + True + False + vertical + + + 150 + True + False + vertical + 4 + + + True + False + 12 + Time gone: + + + False + True + 1 + + + + + True + False + 32 + preferences-system-time-symbolic + + + False + True + 2 + + + + + True + False + 12 + 0:00 + 0 + + + True + True + 3 + + + + + False + False + 0 + + + + + True + False + + + Exit + True + True + True + app.quit + + + False + True + end + 0 + + + + + Empty Time + True + True + True + app.empty + + + False + True + end + 1 + + + + + Pause + True + True + True + app.pause + + + False + True + end + 3 + + + + + Start + True + True + True + app.start + + + False + True + end + 4 + + + + + False + True + 1 + + + + + + diff --git a/Gtkmm3/gtk83_timer2/res/window.ui~ b/Gtkmm3/gtk83_timer2/res/window.ui~ new file mode 100644 index 0000000..f2214ea --- /dev/null +++ b/Gtkmm3/gtk83_timer2/res/window.ui~ @@ -0,0 +1,140 @@ + + + + + + False + + + True + False + vertical + + + 150 + True + False + vertical + 4 + + + True + False + 12 + Time gone: + + + False + True + 1 + + + + + True + False + 32 + preferences-system-time-symbolic + + + False + True + 2 + + + + + True + False + 12 + 0:00 + 0 + + + True + True + 3 + + + + + False + False + 0 + + + + + True + False + + + Exit + True + True + True + app.quit + + + False + True + end + 0 + + + + + Empty Time + True + True + True + app.empty + + + False + True + end + 1 + + + + + Pause + True + True + True + app.pause + + + False + True + end + 3 + + + + + Start + True + True + True + app.start + + + False + True + end + 4 + + + + + False + True + 1 + + + + + + diff --git a/Gtkmm3/gtk83_timer2/src/MyApp.cc b/Gtkmm3/gtk83_timer2/src/MyApp.cc new file mode 100644 index 0000000..52fff57 --- /dev/null +++ b/Gtkmm3/gtk83_timer2/src/MyApp.cc @@ -0,0 +1,50 @@ +#include "MyApp.hh" + +MyApp::MyApp() +:Gtk::Application("org.gtk.daleclack"), +timer_value(1000) +{ + Glib::set_application_name("Gtk83"); +} + +Glib::RefPtr MyApp::create(){ + return Glib::RefPtr(new MyApp()); +} + +void MyApp::on_activate() +{ + //Get builder and main window + ref_builder=Gtk::Builder::create_from_file("../res/window.ui"); + ref_builder->get_widget("main_window",main_window); + main_window->set_icon_name("org.gtk.daleclack"); + //Get widgets + ref_builder->get_widget("clock_label",time_label); + //Add actions + add_action("start",sigc::mem_fun(*this,&MyApp::start_timer)); + add_action("pause",sigc::mem_fun(*this,&MyApp::disconnect_timer)); + add_action("empty",sigc::mem_fun(*this,&MyApp::empty_time)); + add_action("quit",sigc::mem_fun(*this,&MyApp::quit)); + //Show everything + add_window(*main_window); + main_window->show_all(); +} + +void MyApp::start_timer(){ + mytimer=Glib::signal_timeout().connect(sigc::mem_fun(*this,&MyApp::on_timeout),timer_value); +} + +void MyApp::disconnect_timer(){ + mytimer.disconnect(); +} + +void MyApp::empty_time(){ + time_sum=0; + time_label->set_label("0:00"); +} + +bool MyApp::on_timeout(){ + time_sum++; + sprintf(time_string,"%d:%02d",time_sum/60,time_sum%60); + time_label->set_label(time_string); + return true; +} diff --git a/Gtkmm3/gtk83_timer2/src/MyApp.hh b/Gtkmm3/gtk83_timer2/src/MyApp.hh new file mode 100644 index 0000000..7157b2e --- /dev/null +++ b/Gtkmm3/gtk83_timer2/src/MyApp.hh @@ -0,0 +1,31 @@ +#pragma once + +#include + +class MyApp : public Gtk::Application{ +protected: + MyApp(); +public: + static Glib::RefPtr create(); +protected: + void on_activate() override; +private: + //Main Builder + Glib::RefPtr ref_builder; + Gtk::Window *main_window; + + //The Timer + sigc::connection mytimer; + const int timer_value; + bool on_timeout(); + int time_sum=0; + char time_string[20]; + + //Child Widgets + Gtk::Label *time_label; + + //Signal Handlers + void start_timer(); + void disconnect_timer(); + void empty_time(); +}; \ No newline at end of file diff --git a/Gtkmm3/gtk83_timer2/src/main.cc b/Gtkmm3/gtk83_timer2/src/main.cc new file mode 100644 index 0000000..398efd7 --- /dev/null +++ b/Gtkmm3/gtk83_timer2/src/main.cc @@ -0,0 +1,6 @@ +#include "MyApp.hh" + +int main(int argc,char **argv){ + auto app=MyApp::create(); + return app->run(argc,argv); +}