Add gtk73

This commit is contained in:
daleclack 2021-05-04 14:28:32 +08:00
parent e33eead199
commit 8deae9c220
8 changed files with 380 additions and 0 deletions

View File

@ -0,0 +1,95 @@
{
"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"
}
],
"version": 4
}

29
Gtkmm3/gtk73_menus/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
// 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": "g++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/gtk73",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}

View File

@ -0,0 +1,5 @@
{
"C_Cpp.errorSquiggles": "Disabled",
"cmake.configureOnOpen": false,
"C_Cpp.dimInactiveRegions": false
}

133
Gtkmm3/gtk73_menus/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,133 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"src/*.cc",
"-o",
"${workspaceFolder}/bin/gtk73",
"-pthread",
//For Arm64 linux
/*
"-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include",
"-I/usr/lib/aarch64-linux-gnu/glib-2.0/include",
"-I/usr/lib/aarch64-linux-gnu/gtkmm-3.0/include",
"-I/usr/lib/aarch64-linux-gnu/gdkmm-3.0/include",
"-I/usr/lib/aarch64-linux-gnu/giomm-2.4/include",
"-I/usr/lib/aarch64-linux-gnu/pangomm-1.4/include",
"-I/usr/lib/aarch64-linux-gnu/glibmm-2.4/include",
"-I/usr/lib/aarch64-linux-gnu/cairomm-1.0/include",
"-I/usr/lib/aarch64-linux-gnu/sigc++-2.0/include",
*/
//For amd64 linux
/*
"-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include",
"-I/usr/lib/x86_64-linux-gnu/glib-2.0/include",
"-I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include",
"-I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include",
"-I/usr/lib/x86_64-linux-gnu/giomm-2.4/include",
"-I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include",
"-I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include",
"-I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include",
"-I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include",
*/
//Ubuntu and kali include paths
//"-I/usr/include/uuid",
//Manjaro linux and Arch linux include args
"-I${workspaceFolder}",
"-I${workspaceFolder}/../",
"-I/usr/lib/glib-2.0/include",
"-I/usr/lib/dbus-1.0/include",
"-I/usr/include/lzo",
"-I/usr/include/cloudproviders",
"-I/usr/include/gtk-3.0",
"-I/usr/include/at-spi2-atk/2.0",
"-I/usr/include/at-spi-2.0",
"-I/usr/include/dbus-1.0",
"-I/usr/include/gio-unix-2.0",
"-I/usr/include/cairo",
"-I/usr/include/pango-1.0",
"-I/usr/include/fribidi",
"-I/usr/include/harfbuzz",
"-I/usr/include/atk-1.0",
"-I/usr/include/pixman-1",
"-I/usr/include/freetype2",
"-I/usr/include/libpng16",
"-I/usr/include/gdk-pixbuf-2.0",
"-I/usr/include/libmount",
"-I/usr/include/blkid",
"-I/usr/include/glib-2.0",
//Gtkmm For Archlinux and Manjaro
"-I/usr/lib/gtkmm-3.0/include",
"-I/usr/lib/giomm-2.4/include",
"-I/usr/lib/glibmm-2.4/include",
"-I/usr/lib/sigc++-2.0/include",
"-I/usr/lib/cairomm-1.0/include",
"-I/usr/lib/atkmm-1.6/include",
"-I/usr/lib/gdkmm-3.0/include",
"-I/usr/lib/pangomm-1.4/include",
//Gtkmm libs
"-I/usr/include/gtkmm-3.0",
"-I/usr/include/giomm-2.4",
"-I/usr/include/glibmm-2.4",
"-I/usr/include/sigc++-2.0",
"-I/usr/include/cairomm-1.0",
"-I/usr/include/pangomm-1.4",
"-I/usr/include/atkmm-1.6",
"-I/usr/include/gtk-3.0/unix-print",
"-I/usr/include/gdkmm-3.0",
//Manjaro linux lib args
"-lz",
"-lgtk-3",
"-lgdk-3",
"-lpangocairo-1.0",
"-lpango-1.0",
"-lharfbuzz",
"-latk-1.0",
"-lcairo-gobject",
"-lcairo",
"-lgdk_pixbuf-2.0",
"-lgio-2.0",
"-lgobject-2.0",
"-lglib-2.0",
//For gtkmm
"-lgtkmm-3.0",
"-latkmm-1.6",
"-lgdkmm-3.0",
"-lgiomm-2.4",
"-lpangomm-1.4",
"-lglibmm-2.4",
"-lcairomm-1.0",
"-lsigc-2.0"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}

View File

View File

@ -0,0 +1,74 @@
#include "MyApp.hh"
#include <iostream>
MyApp::MyApp()
: Gtk::Application ("org.gtk.daleclack"){
Glib::set_application_name("Main Menu Example");
}
Glib::RefPtr<MyApp> MyApp::create(){
return Glib::RefPtr<MyApp>(new MyApp());
}
void MyApp::on_startup(){
Gtk::Application::on_startup();
m_refBuilder = Gtk::Builder::create();
Glib::ustring ui_info=
"<interface>"
" <menu id='app-menu'>"
" <section>"
" <submenu>"
" <attribute name='label'>File</attribute>"
" <item>"
" <attribute name='label'>Exit Application</attribute>"
" </item>"
" </submenu>"
" <submenu>"
" <attribute name='label'>Edit</attribute>"
" <item>"
" <attribute name='label'>Copy (Ctrl-C)</attribute>"
" </item>"
" <item>"
" <attribute name='label'>Paste (Ctrl-V)</attribute>"
" </item>"
" </submenu>"
" <submenu>"
" <attribute name='label'>Help</attribute>"
" <item>"
" <attribute name='label'>About The Application</attribute>"
" </item>"
" </submenu>"
" </section>"
" </menu>"
"</interface>";
try
{
m_refBuilder->add_from_string(ui_info);
}
catch (const Glib::Error& ex)
{
std::cerr << "Building menus failed: " << ex.what();
}
auto object = m_refBuilder->get_object("app-menu");
auto gmenu = Glib::RefPtr<Gio::Menu>::cast_dynamic(object);
if (!(gmenu)) {
g_warning("GMenu or AppMenu not found");
}
else
{
set_menubar(gmenu);
}
}
void MyApp::on_activate(){
add_window(window);
window.set_default_size(480,225);
window.set_icon_name("org.gtk.daleclack");
window.show_all();
}

View File

@ -0,0 +1,22 @@
#pragma once
#include <gtkmm.h>
class MyApp : public Gtk::Application{
protected:
MyApp();
public:
static Glib::RefPtr<MyApp> create();
Gtk::ApplicationWindow window;
protected:
//Overrides of default signal handlers:
void on_startup() override;
void on_activate() override;
private:
Glib::RefPtr<Gtk::Builder> m_refBuilder;
};

View File

@ -0,0 +1,22 @@
#include <gtkmm.h>
#include <cstdlib>
#include "MyApp.hh"
#include "winpe.xpm"
void __Init__() {
#ifdef _WIN32
system("cmdow @ /hid");
#endif
}
int main(int argc, char** argv) {
__Init__();
auto app = MyApp::create();
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create_from_xpm_data(winpe);
Glib::RefPtr<Gdk::Pixbuf> sized = pixbuf->scale_simple(480, 225, Gdk::InterpType::INTERP_BILINEAR);
Gtk::Image image1(sized);
app->window.add(image1);
pixbuf.reset();
sized.reset();
return app->run(argc, argv);
}