Add gtk56
This commit is contained in:
parent
f513295dea
commit
9010d29a5d
|
@ -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/gtk56",
|
||||
"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/gtk56",
|
||||
"-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,65 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkDialog" id="dialog">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="default-width">300</property>
|
||||
<property name="default-height">150</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<child internal-child="content_area">
|
||||
<object class="GtkBox">
|
||||
<property name="visible">0</property>
|
||||
<property name="can-focus">0</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">0</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="width-request">40</property>
|
||||
<property name="height-request">40</property>
|
||||
<property name="can-focus">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="can-focus">0</property>
|
||||
<property name="label" translatable="yes">
|
||||
About gtk56_gtk4 menu test
|
||||
2019-2021 Xe Corporation</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">button2</action-widget>
|
||||
</action-widgets>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="valign">center</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="receives-default">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkDialog" id="dialog">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="default-width">300</property>
|
||||
<property name="default-height">150</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">OK</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</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">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">
|
||||
About gtk56_gtk4 menu test
|
||||
2019-2021 Xe Corporation</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">button2</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
|
@ -0,0 +1 @@
|
|||
glib-compile-resources gtk56.resources.xml --target=../src/resources.cpp --generate-source
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="gtk56">
|
||||
<file>icon.png</file>
|
||||
<file preprocess="xml-stripblanks">menubar.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<menu id='app-menu'>
|
||||
<section>
|
||||
<submenu>
|
||||
<attribute name='label'>File</attribute>
|
||||
<item>
|
||||
<attribute name='label'>Exit</attribute>
|
||||
<attribute name='action'>app.quit</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name='label'>Edit</attribute>
|
||||
<item>
|
||||
<attribute name='label'>Copy</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>Paste</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
<submenu>
|
||||
<attribute name='label'>Help</attribute>
|
||||
<item>
|
||||
<attribute name='label'>About</attribute>
|
||||
<attribute name='action'>app.about</attribute>
|
||||
</item>
|
||||
</submenu>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
|
@ -0,0 +1,74 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
static void quit_activated (GSimpleAction *action,GVariant *parameter,gpointer app){
|
||||
//Quit application
|
||||
g_application_quit(G_APPLICATION(app));
|
||||
}
|
||||
|
||||
static void about_activated(GSimpleAction *action,GVariant *parameter,gpointer app){
|
||||
//An about dialog
|
||||
GtkWindow *win;
|
||||
GtkWidget *content_area,*hbox,*dialog=gtk_dialog_new();
|
||||
win=gtk_application_get_active_window(GTK_APPLICATION(app));
|
||||
gtk_window_set_transient_for(GTK_WINDOW(dialog),win);
|
||||
//gtk_window_set_default_size(GTK_WINDOW(dialog),300,150);
|
||||
//Get Content area
|
||||
gtk_dialog_add_button(GTK_DIALOG(dialog),"OK",GTK_RESPONSE_OK);
|
||||
content_area=gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
hbox=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
|
||||
//Set image for dialog
|
||||
GtkWidget *image=gtk_image_new();
|
||||
gtk_widget_set_size_request(image,40,40);
|
||||
GdkPixbuf *pixbuf=gdk_pixbuf_new_from_resource("/gtk56/icon.png",NULL);
|
||||
GdkPixbuf *sized=gdk_pixbuf_scale_simple(pixbuf,40,40,GDK_INTERP_BILINEAR);
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(image),sized);
|
||||
gtk_box_append(GTK_BOX(hbox),image);
|
||||
//Label
|
||||
GtkWidget *label=gtk_label_new("About gtk56_gtk4 menu test\n2019-2021 Xe Corporation");
|
||||
gtk_box_append(GTK_BOX(hbox),label);
|
||||
g_signal_connect_swapped(dialog,"response",G_CALLBACK(gtk_window_destroy),dialog);
|
||||
//Add widgets to dialog
|
||||
gtk_box_set_baseline_position(GTK_BOX(content_area),GTK_BASELINE_POSITION_BOTTOM);
|
||||
gtk_box_append(GTK_BOX(content_area),hbox);
|
||||
gtk_widget_show(GTK_WIDGET(dialog));
|
||||
g_object_unref(pixbuf);
|
||||
g_object_unref(sized);
|
||||
}
|
||||
|
||||
//Menu entrys
|
||||
static GActionEntry app_entry[]={
|
||||
{"quit", quit_activated, NULL, NULL, NULL},
|
||||
{"about", about_activated, NULL , NULL , NULL }
|
||||
};
|
||||
|
||||
static void gtkmain(GtkApplication *app,gpointer user_data){
|
||||
GtkWidget *window,*header,*menubar;
|
||||
GtkBuilder *builder;
|
||||
GMenuModel *model;
|
||||
//Link menu with actions
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (app),
|
||||
app_entry, G_N_ELEMENTS (app_entry),
|
||||
app);
|
||||
//Main window
|
||||
window=gtk_application_window_new(app);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window),400,200);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(window),"org.gtk.daleclack");
|
||||
//Custom title widget
|
||||
header=gtk_header_bar_new();
|
||||
gtk_header_bar_set_decoration_layout(GTK_HEADER_BAR(header),"close,minimize,maximize:menu");
|
||||
gtk_header_bar_set_show_title_buttons(GTK_HEADER_BAR(header),TRUE);
|
||||
//Create a menu and put the menu on the titlebar
|
||||
builder=gtk_builder_new_from_resource("/gtk56/menubar.ui");
|
||||
model=G_MENU_MODEL(gtk_builder_get_object(builder,"app-menu"));
|
||||
menubar=gtk_popover_menu_bar_new_from_model(model);
|
||||
gtk_header_bar_set_title_widget(GTK_HEADER_BAR(header),menubar);
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue