Add gtk33

This commit is contained in:
daleclack 2021-01-13 19:00:28 +08:00
parent 8de228e2a3
commit fa83bbdaaa
8 changed files with 321 additions and 0 deletions

View File

@ -0,0 +1,41 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
//For linux amd64 and linux on arm64,some include path may different
"${workspaceFolder}/**",
"/usr/include/gtk-3.0/**",
"/usr/include/gtk-3.0/gtk/**",
"/usr/include/at-spi2-atk/2.0/**",
"/usr/include/at-spi-2.0/**",
"/usr/include/dbus-1.0/**",
"/usr/lib/aarch64-linux-gnu/dbus-1.0/include/**",
"/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/uuid/**",
"/usr/include/freetype2/**",
"/usr/include/libpng16/**",
"/usr/include/gdk-pixbuf-2.0/**",
"/usr/include/libmount/**",
"/usr/include/blkid/**",
"/usr/include/glib-2.0/**",
"/usr/lib/aarch64-linux-gnu/glib-2.0/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-arm64",
"compilerArgs": [
"`pkg-config --cflags --libs gtk+-3.0`"
]
}
],
"version": 4
}

29
Gtk3/gtk33/.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": "${fileDirname}/gtk33",
"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"
}
]
}

3
Gtk3/gtk33/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"C_Cpp.errorSquiggles": "Disabled"
}

62
Gtk3/gtk33/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,62 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"*.cpp",
"-o",
"${fileDirname}/gtk33",
"-pthread",
"-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/lib/aarch64-linux-gnu/dbus-1.0/include",
"-I/usr/include/gtk-3.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/cairo",
"-I/usr/include/pixman-1",
"-I/usr/include/uuid",
"-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",
"-I/usr/lib/aarch64-linux-gnu/glib-2.0/include",
"-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"
}

BIN
Gtk3/gtk33/gtk33 Normal file

Binary file not shown.

35
Gtk3/gtk33/main.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <gtk/gtk.h>
void check_released(GtkApplication *app,gint index){
//Check the selection
switch(index){
case 1:
g_print("button1 checked!\n");break;
case 2:
g_print("button2 checked!\n");break;
}
}
static void gtkmain(GtkApplication *app,gpointer user_data){
//Get window
GtkBuilder *builder=gtk_builder_new_from_file("window.ui");
GObject *window=gtk_builder_get_object(builder,"window");
//Get radiobuttons
GObject *radio1=gtk_builder_get_object(builder,"radiobutton1");
GObject *radio2=gtk_builder_get_object(builder,"radiobutton2");
g_signal_connect(radio1,"released",G_CALLBACK(check_released),(gpointer)1);
g_signal_connect(radio2,"released",G_CALLBACK(check_released),(gpointer)2);
//Get "exit" button
GObject *btnexit=gtk_builder_get_object(builder,"BtnExit");
g_signal_connect_swapped(btnexit,"clicked",G_CALLBACK(gtk_widget_destroy),window);
gtk_application_add_window(app,GTK_WINDOW(window));
gtk_widget_show_all(GTK_WIDGET(window));
}
int main(int argc,char *argv[]){
//Start the application
GtkApplication *app;
app=gtk_application_new("com.github.daleclack.gtk33",G_APPLICATION_FLAGS_NONE);
g_signal_connect(app,"activate",G_CALLBACK(gtkmain),NULL);
return g_application_run(G_APPLICATION(app),argc,argv);
}

75
Gtk3/gtk33/window.ui Normal file
View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
<property name="border-width">10</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkRadioButton" id="radiobutton1">
<property name="label" translatable="yes">1</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="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton2">
<property name="label" translatable="yes">2</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>
<property name="group">radiobutton1</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</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="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

76
Gtk3/gtk33/window.ui~ Normal file
View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="window">
<property name="can-focus">False</property>
<property name="default-width">400</property>
<property name="default-height">300</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkRadioButton" id="radiobutton1">
<property name="label" translatable="yes">1</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="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton2">
<property name="label" translatable="yes">2</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>
<property name="group">radiobutton1</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</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="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>