From 2d8228219d5f844e2136c5bc8c64fe52ac773ce4 Mon Sep 17 00:00:00 2001 From: daleclack Date: Sat, 8 May 2021 21:17:09 +0800 Subject: [PATCH] Add gtk75 --- .../.vscode/c_cpp_properties.json | 95 +++++++++++++ Gtkmm3/gtk75_progress/.vscode/launch.json | 29 ++++ Gtkmm3/gtk75_progress/.vscode/settings.json | 5 + Gtkmm3/gtk75_progress/.vscode/tasks.json | 133 ++++++++++++++++++ Gtkmm3/gtk75_progress/src/GtkWin.cc | 75 ++++++++++ Gtkmm3/gtk75_progress/src/GtkWin.hh | 28 ++++ Gtkmm3/gtk75_progress/src/main.cc | 7 + 7 files changed, 372 insertions(+) create mode 100644 Gtkmm3/gtk75_progress/.vscode/c_cpp_properties.json create mode 100644 Gtkmm3/gtk75_progress/.vscode/launch.json create mode 100644 Gtkmm3/gtk75_progress/.vscode/settings.json create mode 100644 Gtkmm3/gtk75_progress/.vscode/tasks.json create mode 100644 Gtkmm3/gtk75_progress/src/GtkWin.cc create mode 100644 Gtkmm3/gtk75_progress/src/GtkWin.hh create mode 100644 Gtkmm3/gtk75_progress/src/main.cc diff --git a/Gtkmm3/gtk75_progress/.vscode/c_cpp_properties.json b/Gtkmm3/gtk75_progress/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..64210d8 --- /dev/null +++ b/Gtkmm3/gtk75_progress/.vscode/c_cpp_properties.json @@ -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 +} \ No newline at end of file diff --git a/Gtkmm3/gtk75_progress/.vscode/launch.json b/Gtkmm3/gtk75_progress/.vscode/launch.json new file mode 100644 index 0000000..f77c380 --- /dev/null +++ b/Gtkmm3/gtk75_progress/.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/gtk75", + "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/Gtkmm3/gtk75_progress/.vscode/settings.json b/Gtkmm3/gtk75_progress/.vscode/settings.json new file mode 100644 index 0000000..208afcc --- /dev/null +++ b/Gtkmm3/gtk75_progress/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "C_Cpp.errorSquiggles": "Disabled", + "cmake.configureOnOpen": false, + "C_Cpp.dimInactiveRegions": false +} \ No newline at end of file diff --git a/Gtkmm3/gtk75_progress/.vscode/tasks.json b/Gtkmm3/gtk75_progress/.vscode/tasks.json new file mode 100644 index 0000000..69bb8a6 --- /dev/null +++ b/Gtkmm3/gtk75_progress/.vscode/tasks.json @@ -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/gtk75", + "-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" +} diff --git a/Gtkmm3/gtk75_progress/src/GtkWin.cc b/Gtkmm3/gtk75_progress/src/GtkWin.cc new file mode 100644 index 0000000..4ac39f2 --- /dev/null +++ b/Gtkmm3/gtk75_progress/src/GtkWin.cc @@ -0,0 +1,75 @@ +#include "GtkWin.hh" + +GtkWin::GtkWin() +:hbox(Gtk::ORIENTATION_VERTICAL,5), +checkshow("Show text"), +check_activity("Activity Mode"), +check_inverted("Right to Left"), +btn_exit("Exit") +{ + set_icon_name("org.gtk.daleclack"); + set_title("Gtk (75)"); + set_default_size(300,300); + set_border_width(10); + //Initalize Progress Bar + progress1.set_text("Progress Test"); + progress1.set_show_text(); + hbox.pack_start(progress1); + //Add a timer + connection_timeout=Glib::signal_timeout().connect(sigc::mem_fun(*this,&GtkWin::on_timeout),50); + //Check Button + checkshow.signal_clicked().connect(sigc::mem_fun(*this,&GtkWin::checkshow_clicked)); + checkshow.set_active(); + hbox.pack_start(checkshow); + //Activity mode + check_activity.signal_clicked().connect(sigc::mem_fun(*this,&GtkWin::activity_clicked)); + hbox.pack_start(check_activity); + //Inverted Mode + check_inverted.signal_clicked().connect(sigc::mem_fun(*this,&GtkWin::invert_clicked)); + hbox.pack_start(check_inverted); + //"Exit" button + btn_exit.signal_clicked().connect(sigc::mem_fun(*this,&GtkWin::exit_clicked)); + hbox.pack_end(btn_exit); + add(hbox); + show_all(); +} + +void GtkWin::checkshow_clicked(){ + bool checked=checkshow.get_active(); + progress1.set_show_text(checked); +} + +void GtkWin::activity_clicked(){ + activity_mode=check_activity.get_active(); + if(activity_mode){ + progress1.pulse(); + }else{ + progress1.set_fraction(0.0); + } +} + +void GtkWin::invert_clicked(){ + bool inverted=check_inverted.get_active(); + progress1.set_inverted(inverted); +} + +bool GtkWin::on_timeout(){ + //Change the progress Bar Value + if(activity_mode){ + progress1.pulse(); + }else{ + double new_val=progress1.get_fraction()+0.01; + if(new_val>1.0){ + new_val=0.0; + } + progress1.set_fraction(new_val); + } + return true; +} + +void GtkWin::exit_clicked(){ + hide(); +} + +GtkWin::~GtkWin(){ +} \ No newline at end of file diff --git a/Gtkmm3/gtk75_progress/src/GtkWin.hh b/Gtkmm3/gtk75_progress/src/GtkWin.hh new file mode 100644 index 0000000..5bf8360 --- /dev/null +++ b/Gtkmm3/gtk75_progress/src/GtkWin.hh @@ -0,0 +1,28 @@ +#pragma once + +#include + +class GtkWin : public Gtk::Window{ + public: + + GtkWin(); + virtual ~GtkWin(); + + protected: + + bool activity_mode=false; + + //Child widgets + Gtk::ProgressBar progress1; + Gtk::Box hbox; + Gtk::CheckButton checkshow,check_activity,check_inverted; + Gtk::Button btn_exit; + sigc::connection connection_timeout; + + //Signal Handlers + bool on_timeout(); + void checkshow_clicked(); + void activity_clicked(); + void invert_clicked(); + void exit_clicked(); +}; \ No newline at end of file diff --git a/Gtkmm3/gtk75_progress/src/main.cc b/Gtkmm3/gtk75_progress/src/main.cc new file mode 100644 index 0000000..584094e --- /dev/null +++ b/Gtkmm3/gtk75_progress/src/main.cc @@ -0,0 +1,7 @@ +#include "GtkWin.hh" + +int main(int argc,char **argv){ + auto app=Gtk::Application::create(argc,argv,"org.gtk.daleclack"); + GtkWin window; + return app->run(window); +} \ No newline at end of file