Add gtk58
This commit is contained in:
parent
c36d5e7310
commit
15301318f1
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
//This is the gtk4 config file on vscode
|
||||
//Due to no gtk4 on debian and ubuntu till now,the configure only support manjaro(Arch linux may can use it)
|
||||
"${workspaceFolder}/**",
|
||||
"/usr/include/gtk-4.0/**",
|
||||
"/usr/include/pango-1.0/**",
|
||||
"/usr/include/glib-2.0/**",
|
||||
"/usr/lib/glib-2.0/include/**",
|
||||
"/usr/include/harfbuzz/**",
|
||||
"/usr/include/freetype2/**",
|
||||
"/usr/include/libpng16/**",
|
||||
"/usr/include/libmount/**",
|
||||
"/usr/include/blkid/**",
|
||||
"/usr/include/fribidi/**",
|
||||
"/usr/include/cairo/**",
|
||||
"/usr/include/lzo/**",
|
||||
"/usr/include/pixman-1/**",
|
||||
"/usr/include/gdk-pixbuf-2.0/**",
|
||||
"/usr/include/graphene-1.0/**",
|
||||
"/usr/lib/graphene-1.0/include/**",
|
||||
"/usr/include/gio-unix-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
|
||||
}
|
|
@ -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/gtk58",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "Disabled",
|
||||
"cmake.configureOnOpen": false
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++ build active file",
|
||||
"command": "/usr/bin/g++",
|
||||
"args": [
|
||||
"-g",
|
||||
"src/*.cpp",
|
||||
"-o",
|
||||
"${workspaceFolder}/bin/gtk58",
|
||||
"-pthread",
|
||||
"-I${workspaceFolder}/",
|
||||
"-I/usr/include/gtk-4.0",
|
||||
"-I/usr/include/pango-1.0",
|
||||
"-I/usr/include/glib-2.0",
|
||||
"-I/usr/lib/glib-2.0/include",
|
||||
"-I/usr/include/harfbuzz",
|
||||
"-I/usr/include/freetype2",
|
||||
"-I/usr/include/libpng16",
|
||||
"-I/usr/include/libmount",
|
||||
"-I/usr/include/blkid",
|
||||
"-I/usr/include/fribidi",
|
||||
"-I/usr/include/cairo",
|
||||
"-I/usr/include/lzo",
|
||||
"-I/usr/include/pixman-1",
|
||||
"-I/usr/include/gdk-pixbuf-2.0",
|
||||
"-I/usr/include/graphene-1.0",
|
||||
"-I/usr/lib/graphene-1.0/include",
|
||||
"-I/usr/include/gio-unix-2.0",
|
||||
"-mfpmath=sse",
|
||||
"-msse",
|
||||
"-msse2",
|
||||
"-lgtk-4",
|
||||
"-lpangocairo-1.0",
|
||||
"-lpango-1.0",
|
||||
"-lharfbuzz",
|
||||
"-lgdk_pixbuf-2.0",
|
||||
"-lcairo-gobject",
|
||||
"-lcairo",
|
||||
"-lvulkan",
|
||||
"-lgraphene-1.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"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
glib-compile-resources gtk57.resource.xml --target=../src/resources.cpp --generate-source
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="gtk57">
|
||||
<file preprocess="xml-stripblanks">menubar.xml</file>
|
||||
</gresource>
|
||||
</gresources>
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id='app-menu'>
|
||||
<section>
|
||||
<submenu>
|
||||
<attribute name='label'>Config</attribute>
|
||||
<item>
|
||||
<attribute name='label'>Change Config1</attribute>
|
||||
<attribute name='action'>app.config1</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Change Config2</attribute>
|
||||
<attribute name='action'>app.config2</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Change Config3</attribute>
|
||||
<attribute name='action'>app.config3</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
<item>
|
||||
<attribute name='label'>About</attribute>
|
||||
<attribute name='action'>app.about</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Exit</attribute>
|
||||
<attribute name='action'>app.quit</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
|
@ -0,0 +1,101 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
static void MsgBox(const gchar *msg,gpointer app){
|
||||
GtkWidget *dialog,*vbox,*label2;
|
||||
GtkWindow *win;
|
||||
//Initalize window
|
||||
dialog=gtk_dialog_new();
|
||||
gtk_window_set_default_size(GTK_WINDOW(dialog),300,150);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(dialog),"org.gtk.daleclack");
|
||||
win=gtk_application_get_active_window(GTK_APPLICATION(app));
|
||||
gtk_window_set_transient_for(GTK_WINDOW(dialog),win);
|
||||
gtk_dialog_add_button(GTK_DIALOG(dialog),"OK",GTK_RESPONSE_OK);
|
||||
vbox=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
//label1=gtk_label_new(" ");
|
||||
//gtk_box_pack_start(GTK_BOX(vbox),label1,TRUE,TRUE,0);
|
||||
label2=gtk_label_new(msg);
|
||||
//gtk_box_pack_start(GTK_BOX(vbox),label2,TRUE,TRUE,0);
|
||||
gtk_widget_set_hexpand(label2,TRUE);
|
||||
gtk_widget_set_vexpand(label2,TRUE);
|
||||
gtk_box_append(GTK_BOX(vbox),label2);
|
||||
g_signal_connect_swapped(dialog,"response",G_CALLBACK(gtk_window_destroy),dialog);
|
||||
gtk_widget_show(dialog);
|
||||
}
|
||||
|
||||
static void config1_activated(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer app)
|
||||
{
|
||||
MsgBox("Config1",app);
|
||||
}
|
||||
|
||||
static void config2_activated(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer app)
|
||||
{
|
||||
MsgBox("Config2",app);
|
||||
}
|
||||
|
||||
static void config3_activated(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer app)
|
||||
{
|
||||
MsgBox("Config3",app);
|
||||
}
|
||||
|
||||
static void about_activated(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer app)
|
||||
{
|
||||
MsgBox("About gtk57\nA GtkPopover test(Gtk3 Version)",app);
|
||||
}
|
||||
|
||||
static void quit_activated(GSimpleAction *action,
|
||||
GVariant *parameter,
|
||||
gpointer app)
|
||||
{
|
||||
g_application_quit(G_APPLICATION(app));
|
||||
}
|
||||
|
||||
static GActionEntry app_entry[] =
|
||||
{
|
||||
{"quit",quit_activated,NULL,NULL,NULL},
|
||||
{"about",about_activated,NULL,NULL,NULL},
|
||||
{"config1",config1_activated,NULL,NULL,NULL},
|
||||
{"config2",config2_activated,NULL,NULL,NULL},
|
||||
{"config3",config3_activated,NULL,NULL,NULL}
|
||||
};
|
||||
|
||||
static void gtkmain(GtkApplication *app,gpointer user_data){
|
||||
GtkWidget *window,*header,*menubtn,*popover;
|
||||
GtkBuilder *builder=gtk_builder_new_from_resource("/gtk57/menubar.xml");
|
||||
GMenuModel *model;
|
||||
//Initalize window
|
||||
window=gtk_application_window_new(app);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(window),"org.gtk.daleclack");
|
||||
gtk_window_set_default_size(GTK_WINDOW(window),400,240);
|
||||
gtk_window_set_title(GTK_WINDOW(window),"gtk (57)");
|
||||
g_action_map_add_action_entries(G_ACTION_MAP(app),app_entry,
|
||||
G_N_ELEMENTS (app_entry),app);
|
||||
//Header bar
|
||||
header=gtk_header_bar_new();
|
||||
gtk_header_bar_set_show_title_buttons(GTK_HEADER_BAR(header),TRUE);
|
||||
//gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),TRUE);
|
||||
//gtk_header_bar_set_title(GTK_HEADER_BAR(header),"gtk (57)");
|
||||
//A application menu
|
||||
menubtn=gtk_menu_button_new();
|
||||
model=G_MENU_MODEL(gtk_builder_get_object(builder,"app-menu"));
|
||||
popover=gtk_popover_menu_new_from_model(model);
|
||||
//popover=gtk_popover_new_from_model(menubtn,model);
|
||||
gtk_header_bar_pack_end(GTK_HEADER_BAR(header),menubtn);
|
||||
gtk_menu_button_set_popover(GTK_MENU_BUTTON(menubtn),popover);
|
||||
gtk_window_set_titlebar(GTK_WINDOW(window),header);
|
||||
gtk_widget_show(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);
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue