Add gtk93
This commit is contained in:
parent
5593aceae6
commit
a609f89e5f
|
@ -0,0 +1,26 @@
|
|||
#A Simple Project Test
|
||||
project('gtk93', '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-4.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('gtk93', icon_res, 'src/main.cc', 'src/MyWin.cc', dependencies : gtkdep,
|
||||
win_subsystem : 'windows')
|
||||
else
|
||||
executable('gtk93', 'src/main.cc', 'src/MyWin.cc', dependencies : gtkdep)
|
||||
endif
|
|
@ -0,0 +1,33 @@
|
|||
#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.append(label1);
|
||||
main_box.append(fontbtn);
|
||||
main_box.set_halign(Gtk::Align::CENTER);
|
||||
main_box.set_valign(Gtk::Align::CENTER);
|
||||
|
||||
//Add everything
|
||||
set_child(main_box);
|
||||
//show_all_children();
|
||||
}
|
||||
|
||||
void MyWin::font_changed(){
|
||||
Pango::FontDescription descript(fontbtn.get_font());
|
||||
auto font=Pango::AttrFontDesc::create_attr_font_desc(descript);
|
||||
Pango::AttrList list;
|
||||
list.insert(font);
|
||||
label1.set_attributes(list);
|
||||
}
|
|
@ -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,6 @@
|
|||
#include "MyWin.hh"
|
||||
|
||||
int main(int argc,char **argv){
|
||||
auto app=Gtk::Application::create("org.gtk.daleclack");
|
||||
return app->make_window_and_run<MyWin>(argc,argv);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) 启动",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/builddir/gtk91",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"preLaunchTask": "Meson: Build target",
|
||||
"MIMode": "gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "为 gdb 启用整齐打印",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "meson",
|
||||
"target": "gtk91",
|
||||
"mode": "build",
|
||||
"group": "build",
|
||||
"problemMatcher": [],
|
||||
"label": "Meson: Build target"
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
Loading…
Reference in New Issue