Add gtk104

This commit is contained in:
daleclack 2021-08-25 10:34:57 +08:00
parent 01e869aaf1
commit a2ca39dddf
4 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#A Simple Project Test
project('gtk104', 'cpp',
default_options : ['c_std=c17', 'cpp_std=c++17'])
#Initalize variants
# gnome=import('gnome')
#Compile Resource
# gresources = gnome.compile_resources(
# 'resources', 'res/gtk91.resource.xml',
# source_dir: 'res',
# c_name: 'resources'
# )
#The Gtkmm Library as a dependency
gtkdep = dependency('gtkmm-3.0')
#Additional include dirs
dir_include = include_directories('..')
#source files
src=['src/main.cc', 'src/MyWin.cc', '../cfgfile2/cfgfile.cc']
#Use Different Build Opinions in windows and Linux
if host_machine.system() == 'windows'
win=import('windows')
icon_res=win.compile_resources('../icon.rc')
executable('gtk104', icon_res, src, dependencies : gtkdep,
win_subsystem : 'windows', include_directories : dir_include)
else
executable('gtk104', src, dependencies : gtkdep, include_directories : dir_include)
endif

View File

@ -0,0 +1,21 @@
#include "MyWin.hh"
#include "winpe.xpm"
#include <ctime>
MyWin::MyWin()
{
set_icon_name("org.gtk.daleclack");
myconnection=Glib::signal_timeout().connect(sigc::mem_fun(*this,&MyWin::on_timeout),1000);
}
bool MyWin::on_timeout(){
time_t t;
t=time(NULL);
struct tm *local;
local=localtime(&t);
if(local->tm_hour == 10 && local->tm_min == 50){
Gtk::MessageDialog dialog("Time out!");
dialog.run();
}
return true;
}

View File

@ -0,0 +1,14 @@
#pragma once
#include <gtkmm.h>
#include "../cfgfile2/cfgfile.hh"
class MyWin : public Gtk::Window{
public:
MyWin();
private:
//TimeOut Control
sigc::connection myconnection;
//Signal Handler
bool on_timeout();
};

View File

@ -0,0 +1,7 @@
#include "MyWin.hh"
int main(int argc,char **argv){
auto app=Gtk::Application::create(argc,argv,"org.gtk.daleclack");
MyWin window;
return app->run(window);
}