From 239978e4bf3e03945635d3fdf19439244469f845 Mon Sep 17 00:00:00 2001 From: daleclack Date: Sun, 28 Mar 2021 08:39:36 +0800 Subject: [PATCH] Add gtk53 --- .../.vscode/c_cpp_properties.json | 59 +++++++++++++ Gtk3/gtk53_runner2/.vscode/launch.json | 29 +++++++ Gtk3/gtk53_runner2/.vscode/settings.json | 4 + Gtk3/gtk53_runner2/.vscode/tasks.json | 82 +++++++++++++++++++ Gtk3/gtk53_runner2/Makefile.win | 32 ++++++++ Gtk3/gtk53_runner2/compile-resource.sh | 1 + Gtk3/gtk53_runner2/gtk53.gresource.xml | 6 ++ Gtk3/gtk53_runner2/gtk53_runner2.dev | 79 ++++++++++++++++++ Gtk3/gtk53_runner2/gtk53_runner2.layout | 13 +++ Gtk3/gtk53_runner2/main.cpp | 38 +++++++++ Gtk3/gtk53_runner2/window.ui | 78 ++++++++++++++++++ Gtk3/gtk53_runner2/window.ui~ | 78 ++++++++++++++++++ 12 files changed, 499 insertions(+) create mode 100644 Gtk3/gtk53_runner2/.vscode/c_cpp_properties.json create mode 100644 Gtk3/gtk53_runner2/.vscode/launch.json create mode 100644 Gtk3/gtk53_runner2/.vscode/settings.json create mode 100644 Gtk3/gtk53_runner2/.vscode/tasks.json create mode 100644 Gtk3/gtk53_runner2/Makefile.win create mode 100644 Gtk3/gtk53_runner2/compile-resource.sh create mode 100644 Gtk3/gtk53_runner2/gtk53.gresource.xml create mode 100644 Gtk3/gtk53_runner2/gtk53_runner2.dev create mode 100644 Gtk3/gtk53_runner2/gtk53_runner2.layout create mode 100644 Gtk3/gtk53_runner2/main.cpp create mode 100644 Gtk3/gtk53_runner2/window.ui create mode 100644 Gtk3/gtk53_runner2/window.ui~ diff --git a/Gtk3/gtk53_runner2/.vscode/c_cpp_properties.json b/Gtk3/gtk53_runner2/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..99fbbb6 --- /dev/null +++ b/Gtk3/gtk53_runner2/.vscode/c_cpp_properties.json @@ -0,0 +1,59 @@ +{ + "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", + */ + //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", + */ + //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}/**", + "/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/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++14", + "intelliSenseMode": "gcc-arm64", + "compilerArgs": [ + "`pkg-config --cflags --libs gtk+-3.0`" + ], + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Gtk3/gtk53_runner2/.vscode/launch.json b/Gtk3/gtk53_runner2/.vscode/launch.json new file mode 100644 index 0000000..8c6bd55 --- /dev/null +++ b/Gtk3/gtk53_runner2/.vscode/launch.json @@ -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/gtk53", + "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" + } + ] +} diff --git a/Gtk3/gtk53_runner2/.vscode/settings.json b/Gtk3/gtk53_runner2/.vscode/settings.json new file mode 100644 index 0000000..0baae3a --- /dev/null +++ b/Gtk3/gtk53_runner2/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "C_Cpp.errorSquiggles": "Disabled", + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/Gtk3/gtk53_runner2/.vscode/tasks.json b/Gtk3/gtk53_runner2/.vscode/tasks.json new file mode 100644 index 0000000..9124a7a --- /dev/null +++ b/Gtk3/gtk53_runner2/.vscode/tasks.json @@ -0,0 +1,82 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-g", + "*.cpp", + "-o", + "${workspaceFolder}/bin/gtk53", + "-pthread", + //For Arm64 linux + /* + "-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include", + "-I/usr/lib/aarch64-linux-gnu/glib-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", + */ + //Ubuntu and kali include paths + /* + "-I/usr/include/uuid", + */ + //Manjaro linux and Arch linux include args + + "-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", + //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", + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} diff --git a/Gtk3/gtk53_runner2/Makefile.win b/Gtk3/gtk53_runner2/Makefile.win new file mode 100644 index 0000000..7c7df67 --- /dev/null +++ b/Gtk3/gtk53_runner2/Makefile.win @@ -0,0 +1,32 @@ +# Project: gtk53_runner2 +# Makefile created by Dev-C++ 6.6 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +OBJ = main.o resource.o +LINKOBJ = main.o resource.o +LIBS = -L"C:/Dev-Cpp/MinGW64/lib" -L"C:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libstdc++ -static-libgcc -mms-bitfields -lgtk-3 -lgdk-3 -lz -lgdi32 -limm32 -lshell32 -lole32 -Wl,-luuid -lwinmm -ldwmapi -lsetupapi -lcfgmgr32 -lpangowin32-1.0 -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 -lintl -mwindows -s +INCS = -I"C:/Dev-Cpp/MinGW64/include" -I"C:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/10.2.0/include" -I"C:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/10.2.0/include-fixed" -I"C:/Dev-Cpp/mingw64/include/gtk-3.0" -I"C:/Dev-Cpp/mingw64/include/pango-1.0" -I"C:/Dev-Cpp/mingw64/include" -I"C:/Dev-Cpp/mingw64/include/glib-2.0" -I"C:/Dev-Cpp/mingw64/lib/glib-2.0/include" -I"C:/Dev-Cpp/mingw64/include/harfbuzz" -I"C:/Dev-Cpp/mingw64/include/freetype2" -I"C:/Dev-Cpp/mingw64/include/libpng16" -I"C:/Dev-Cpp/mingw64/include/fribidi" -I"C:/Dev-Cpp/mingw64/include/cairo" -I"C:/Dev-Cpp/mingw64/include/lzo" -I"C:/Dev-Cpp/mingw64/include/pixman-1" -I"C:/Dev-Cpp/mingw64/include/atk-1.0" -I"C:/Dev-Cpp/mingw64/include/gdk-pixbuf-2.0" +CXXINCS = -I"C:/Dev-Cpp/MinGW64/include" -I"C:/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/10.2.0/include" -I"C:/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/10.2.0/include-fixed" -I"C:/Dev-Cpp/MinGW64/include/c++/10.2.0" -I"C:/Dev-Cpp/MinGW64/include/c++/10.2.0/x86_64-w64-mingw32" -I"C:/Dev-Cpp/MinGW64/include/c++/10.2.0/backward" -I"C:/Dev-Cpp/mingw64/include/gtk-3.0" -I"C:/Dev-Cpp/mingw64/include/pango-1.0" -I"C:/Dev-Cpp/mingw64/include" -I"C:/Dev-Cpp/mingw64/include/glib-2.0" -I"C:/Dev-Cpp/mingw64/lib/glib-2.0/include" -I"C:/Dev-Cpp/mingw64/include/harfbuzz" -I"C:/Dev-Cpp/mingw64/include/freetype2" -I"C:/Dev-Cpp/mingw64/include/libpng16" -I"C:/Dev-Cpp/mingw64/include/fribidi" -I"C:/Dev-Cpp/mingw64/include/cairo" -I"C:/Dev-Cpp/mingw64/include/lzo" -I"C:/Dev-Cpp/mingw64/include/pixman-1" -I"C:/Dev-Cpp/mingw64/include/atk-1.0" -I"C:/Dev-Cpp/mingw64/include/gdk-pixbuf-2.0" +BIN = gtk53_runner2.exe +CXXFLAGS = $(CXXINCS) -O2 -mwindows -pthread +ENCODINGS = -finput-charset=utf-8 -fexec-charset=gbk +CFLAGS = $(INCS) -O2 -mwindows -pthread +RM = rm.exe -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before $(BIN) all-after + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +$(BIN): $(OBJ) + $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS) + +main.o: main.cpp + $(CPP) -c main.cpp -o main.o $(CXXFLAGS) $(ENCODINGS) + +resource.o: resource.cpp + $(CPP) -c resource.cpp -o resource.o $(CXXFLAGS) $(ENCODINGS) diff --git a/Gtk3/gtk53_runner2/compile-resource.sh b/Gtk3/gtk53_runner2/compile-resource.sh new file mode 100644 index 0000000..f598cf1 --- /dev/null +++ b/Gtk3/gtk53_runner2/compile-resource.sh @@ -0,0 +1 @@ + glib-compile-resources gtk53.gresource.xml --target=resources.cpp --generate-source diff --git a/Gtk3/gtk53_runner2/gtk53.gresource.xml b/Gtk3/gtk53_runner2/gtk53.gresource.xml new file mode 100644 index 0000000..1d2b4a4 --- /dev/null +++ b/Gtk3/gtk53_runner2/gtk53.gresource.xml @@ -0,0 +1,6 @@ + + + + window.ui + + diff --git a/Gtk3/gtk53_runner2/gtk53_runner2.dev b/Gtk3/gtk53_runner2/gtk53_runner2.dev new file mode 100644 index 0000000..f7c9b51 --- /dev/null +++ b/Gtk3/gtk53_runner2/gtk53_runner2.dev @@ -0,0 +1,79 @@ +[Project] +FileName=gtk53_runner2.dev +Name=gtk53_runner2 +Type=1 +Ver=2 +ObjFiles= +Includes= +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker= +IsCpp=1 +Icon= +ExeOutput= +ObjectOutput= +LogOutput= +LogOutputEnabled=0 +OverrideOutput=0 +OverrideOutputName= +HostApplication= +UseCustomMakefile=0 +CustomMakefile= +UsePrecompiledHeader=0 +PrecompiledHeader= +CommandLine= +Folders= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=3 +CompilerSettings=000000a000000000000110000 +UseUTF8=1 +UnitCount=2 + +[VersionInfo] +Major=1 +Minor=0 +Release=0 +Build=0 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 +SyncProduct=1 + +[Unit1] +FileName=main.cpp +CompileCpp=1 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +DetectEncoding=0 +Encoding=1 + +[Unit2] +FileName=resource.cpp +CompileCpp=1 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= +DetectEncoding=0 +Encoding=1 + diff --git a/Gtk3/gtk53_runner2/gtk53_runner2.layout b/Gtk3/gtk53_runner2/gtk53_runner2.layout new file mode 100644 index 0000000..0739188 --- /dev/null +++ b/Gtk3/gtk53_runner2/gtk53_runner2.layout @@ -0,0 +1,13 @@ +[Editors] +Order=0,1 +Focused=0 +[Editor_0] +CursorCol=1 +CursorRow=17 +TopLine=1 +LeftChar=1 +[Editor_1] +CursorCol=1 +CursorRow=1 +TopLine=1 +LeftChar=1 diff --git a/Gtk3/gtk53_runner2/main.cpp b/Gtk3/gtk53_runner2/main.cpp new file mode 100644 index 0000000..afe1dbe --- /dev/null +++ b/Gtk3/gtk53_runner2/main.cpp @@ -0,0 +1,38 @@ +#include +#include + +void run_code(GtkWidget *widget,GtkBuilder *builder){ + GObject *window,*check1,*entry; + const char *str; + gboolean flag; + window=gtk_builder_get_object(builder,"window"); + check1=gtk_builder_get_object(builder,"check1"); + entry=gtk_builder_get_object(builder,"entry"); + str=gtk_entry_get_text(GTK_ENTRY(entry)); + std::thread first (system,str); + first.detach(); + flag=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check1)); + if(flag==TRUE) gtk_widget_destroy(GTK_WIDGET(window)); +} + +static void gtkmain(GtkApplication *app,gpointer user_data){ + GtkBuilder *builder=gtk_builder_new_from_resource("/gtk53/window.ui"); + GObject *window,*entry,*btnok,*btncancel; + window=gtk_builder_get_object(builder,"window"); + gtk_application_add_window(app,GTK_WINDOW(window)); + entry=gtk_builder_get_object(builder,"entry"); + gtk_entry_set_text(GTK_ENTRY(entry),"cmd"); + g_signal_connect(entry,"activate",G_CALLBACK(run_code),builder); + btnok=gtk_builder_get_object(builder,"btnok"); + g_signal_connect(btnok,"clicked",G_CALLBACK(run_code),builder); + btncancel=gtk_builder_get_object(builder,"btncancel"); + g_signal_connect_swapped(btncancel,"clicked",G_CALLBACK(gtk_widget_destroy),window); + gtk_widget_show_all(GTK_WIDGET(window)); +} + +int main(int argc,char **argv){ + GtkApplication *app; + app=gtk_application_new("org.gtk.daleclack",G_APPLICATION_NON_UNIQUE); + g_signal_connect(app,"activate",G_CALLBACK(gtkmain),NULL); + return g_application_run(G_APPLICATION(app),argc,argv); +} diff --git a/Gtk3/gtk53_runner2/window.ui b/Gtk3/gtk53_runner2/window.ui new file mode 100644 index 0000000..8d2b356 --- /dev/null +++ b/Gtk3/gtk53_runner2/window.ui @@ -0,0 +1,78 @@ + + + + + + False + + + True + False + vertical + + + True + True + + + False + True + 0 + + + + + Destroy window on run + True + True + False + True + + + False + True + 1 + + + + + True + False + end + + + Cancel + True + True + True + + + True + True + 0 + + + + + OK + True + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + + diff --git a/Gtk3/gtk53_runner2/window.ui~ b/Gtk3/gtk53_runner2/window.ui~ new file mode 100644 index 0000000..9617376 --- /dev/null +++ b/Gtk3/gtk53_runner2/window.ui~ @@ -0,0 +1,78 @@ + + + + + + False + + + True + False + vertical + + + True + True + + + False + True + 0 + + + + + checkbutton + True + True + False + True + + + False + True + 1 + + + + + True + False + end + + + button + True + True + True + + + True + True + 0 + + + + + button + True + True + True + + + True + True + 1 + + + + + False + True + 2 + + + + + +