Add gtk91
This commit is contained in:
parent
ddf1b9fcb0
commit
5593aceae6
|
@ -0,0 +1,26 @@
|
|||
#A Simple Project Test
|
||||
project('gtk91', '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')
|
||||
|
||||
#Use Different Build Opinions in windows and Linux
|
||||
if host_machine.system() == 'windows'
|
||||
win=import('windows')
|
||||
icon_res=win.compile_resources('icon.rc')
|
||||
executable('gtk91', icon_res, 'src/main.cc', 'src/MyWin.cc', dependencies : gtkdep,
|
||||
win_subsystem : 'windows')
|
||||
else
|
||||
executable('gtk91', 'src/main.cc', 'src/MyWin.cc', dependencies : gtkdep)
|
||||
endif
|
|
@ -0,0 +1,30 @@
|
|||
#include "MyWin.hh"
|
||||
#include <iostream>
|
||||
|
||||
MyWin::MyWin()
|
||||
:fontbtn("Sans 10"),
|
||||
label1("Simple Text"),
|
||||
main_box(Gtk::ORIENTATION_VERTICAL,5)
|
||||
{
|
||||
//Ininalize window
|
||||
set_icon_name("org.gtk.daleclack");
|
||||
set_default_size(400,300);
|
||||
set_title("Font Dialog");
|
||||
|
||||
//Add Button
|
||||
fontbtn.set_use_font();
|
||||
fontbtn.signal_font_set().connect(sigc::mem_fun(*this,&MyWin::font_changed));
|
||||
main_box.pack_start(label1,Gtk::PACK_SHRINK);
|
||||
main_box.pack_start(fontbtn,Gtk::PACK_SHRINK);
|
||||
main_box.set_halign(Gtk::ALIGN_CENTER);
|
||||
main_box.set_valign(Gtk::ALIGN_CENTER);
|
||||
|
||||
//Add everything
|
||||
add(main_box);
|
||||
show_all_children();
|
||||
}
|
||||
|
||||
void MyWin::font_changed(){
|
||||
Pango::FontDescription descript(fontbtn.get_font_name());
|
||||
label1.override_font(descript);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
class MyWin : public Gtk::Window{
|
||||
public:
|
||||
MyWin();
|
||||
private:
|
||||
//Child Widgets
|
||||
Gtk::FontButton fontbtn;
|
||||
Gtk::Label label1;
|
||||
Gtk::Box main_box;
|
||||
//Signal Handlers
|
||||
void font_changed();
|
||||
};
|
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue