Add gtk74

This commit is contained in:
daleclack 2021-05-04 20:50:26 +08:00
parent 932100393c
commit 3fc9254867
11 changed files with 715 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/gtk74_scale/.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/gtk74_scale/.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,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="gtk74">
<file preprocess="xml-stripblanks">window.ui</file>
</gresource>
</gresources>

View File

@ -0,0 +1,315 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">5</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
<property name="border-width">5</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">20</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkScale" id="scale1">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="orientation">vertical</property>
<property name="adjustment">adjustment1</property>
<property name="round-digits">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkScale" id="scale2">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="round-digits">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkScrollbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="adjustment">adjustment1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="btnshow">
<property name="label" translatable="yes">Display Value on scale widgets</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Scale Value Position:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkComboBoxText" id="combo_pos">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="active">0</property>
<items>
<item>Top</item>
<item>Bottom</item>
<item>Left</item>
<item>Right</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Scale Update Policy:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkComboBoxText" id="combo_update">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="active">1</property>
<items>
<item>Continuous</item>
<item>Discontinuous</item>
<item>Delayed</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Scale Digits:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="digit_scale">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="round-digits">1</property>
<property name="digits">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Scrollbar page size:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScale" id="size_scale">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adjustment3</property>
<property name="round-digits">0</property>
<property name="digits">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkButton" id="btnexit">
<property name="label" translatable="yes">Exit</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,82 @@
#include "MyApp.hh"
Glib::RefPtr<MyApp> MyApp::create() {
return Glib::RefPtr<MyApp>(new MyApp());
}
void MyApp::on_activate() {
//Create a builder and get widgets
m_builder = Gtk::Builder::create_from_resource("/gtk74/window.ui");
//Main window
m_builder->get_widget("window", window);
window->set_title("Gtk (74)");
add_window(*window);
//Show Value Button
m_builder->get_widget("btnshow", btn_check);
btn_check->signal_clicked().connect(sigc::mem_fun(*this, &MyApp::btncheck_clicked));
//Scale buttons
m_builder->get_widget("scale1", scale1);
m_builder->get_widget("scale2", scale2);
//Position ComboBox
m_builder->get_widget("combo_pos", combo_pos);
combo_pos->signal_changed().connect(sigc::mem_fun(*this, &MyApp::combopos_changed));
//Digit setting
m_builder->get_widget("digit_scale", digit_scale);
digit_scale->signal_value_changed().connect(sigc::mem_fun(*this, &MyApp::digit_changed));
//Page size Setting
object = m_builder->get_object("adjustment1");
main_value = Glib::RefPtr<Gtk::Adjustment>::cast_static(object);
m_builder->get_widget("size_scale", size_scale);
size_scale->signal_value_changed().connect(sigc::mem_fun(*this, &MyApp::size_changed));
//Exit Button
m_builder->get_widget("btnexit", btn_exit);
btn_exit->signal_clicked().connect(sigc::mem_fun(*this, &MyApp::btnexit_clicked));
window->show_all();
}
void MyApp::btncheck_clicked() {
bool checked;
checked = btn_check->get_active();
scale1->set_draw_value(checked);
scale2->set_draw_value(checked);
}
void MyApp::combopos_changed() {
//Change the position of scales
int index;
index = combo_pos->get_active_row_number();
Gtk::PositionType pos = Gtk::PositionType::POS_TOP;
//g_print("%d\n", index);
switch (index) {
case 0:
pos = Gtk::PositionType::POS_TOP; break;
case 1:
pos = Gtk::PositionType::POS_BOTTOM; break;
case 2:
pos = Gtk::PositionType::POS_LEFT; break;
case 3:
pos = Gtk::PositionType::POS_RIGHT; break;
}
scale1->set_value_pos(pos);
scale2->set_value_pos(pos);
}
void MyApp::digit_changed() {
//Change Digits
int digits;
digits = digit_scale->get_value();
scale1->set_digits(digits);
scale2->set_digits(digits);
}
void MyApp::size_changed() {
//Change Page Size
double page_size;
page_size = size_scale->get_value();
//g_print("%f\n", page_size);
main_value->set_page_size(page_size);
}
void MyApp::btnexit_clicked() {
delete window;
}

View File

@ -0,0 +1,36 @@
#pragma once
#include <gtkmm.h>
class MyApp
:public Gtk::Application
{
public:
static Glib::RefPtr<MyApp> create();
protected:
void on_activate() override;
private:
Glib::RefPtr<Gtk::Builder> m_builder;
Gtk::Window* window;
Glib::RefPtr<Glib::Object> object;
Glib::RefPtr<Gtk::Adjustment> main_value;
Gtk::Scale* scale1;
Gtk::Scale* scale2;
Gtk::ComboBox* combo_pos;
Gtk::Scale* digit_scale;
Gtk::Scale* size_scale;
Gtk::CheckButton* btn_check;
Gtk::Button* btn_exit;
void btncheck_clicked();
void combopos_changed();
void digit_changed();
void size_changed();
void btnexit_clicked();
};

View File

@ -0,0 +1,14 @@
#include <cstdlib>
#include "MyApp.hh"
void __App_Init() {
#ifdef _WIN32
system("cmdow @ /hid");
#endif
}
int main(int argc, char** argv) {
__App_Init();
auto app = MyApp::create();
return app->run(argc, argv);
}

Binary file not shown.