Add gtk83
This commit is contained in:
parent
77448bd07d
commit
f6b3816901
|
@ -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
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "Disabled",
|
||||
"cmake.configureOnOpen": false,
|
||||
"C_Cpp.dimInactiveRegions": false
|
||||
}
|
|
@ -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})
|
|
@ -0,0 +1,3 @@
|
|||
cd build_mingw
|
||||
mingw32-make
|
||||
gtk83
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkWindow" id="main_window">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="icon-name">org.gtk.daleclack</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="main_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="time_box">
|
||||
<property name="width-request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label">Time gone:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="clock_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="pixel-size">32</property>
|
||||
<property name="icon-name">preferences-system-time-symbolic</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="clock_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label">0:00</property>
|
||||
<property name="yalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="buttons_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_exit">
|
||||
<property name="label" translatable="yes">Exit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.quit</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_empty">
|
||||
<property name="label" translatable="yes">Empty Time</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.empty</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="Pause">
|
||||
<property name="label" translatable="yes">Pause</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.pause</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_start">
|
||||
<property name="label" translatable="yes">Start</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkWindow" id="main_window">
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="main_vbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="time_box">
|
||||
<property name="width-request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">4</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label">Time gone:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="clock_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="pixel-size">32</property>
|
||||
<property name="icon-name">preferences-system-time-symbolic</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="clock_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="label">0:00</property>
|
||||
<property name="yalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="buttons_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_exit">
|
||||
<property name="label" translatable="yes">Exit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.quit</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_empty">
|
||||
<property name="label" translatable="yes">Empty Time</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.empty</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="Pause">
|
||||
<property name="label" translatable="yes">Pause</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.pause</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="btn_start">
|
||||
<property name="label" translatable="yes">Start</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="action-name">app.start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -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> MyApp::create(){
|
||||
return Glib::RefPtr<MyApp>(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;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
class MyApp : public Gtk::Application{
|
||||
protected:
|
||||
MyApp();
|
||||
public:
|
||||
static Glib::RefPtr<MyApp> create();
|
||||
protected:
|
||||
void on_activate() override;
|
||||
private:
|
||||
//Main Builder
|
||||
Glib::RefPtr<Gtk::Builder> 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();
|
||||
};
|
|
@ -0,0 +1,6 @@
|
|||
#include "MyApp.hh"
|
||||
|
||||
int main(int argc,char **argv){
|
||||
auto app=MyApp::create();
|
||||
return app->run(argc,argv);
|
||||
}
|
Loading…
Reference in New Issue