diff --git a/Gtk3/gtk69_Ui3_test/.vscode/c_cpp_properties.json b/Gtk3/gtk69_Ui3_test/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..4078427 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/.vscode/c_cpp_properties.json @@ -0,0 +1,61 @@ +{ + "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", + */ + //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", + */ + //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}/**", + "/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/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++14", + "intelliSenseMode": "gcc-x64", + "compilerArgs": [ + "`pkg-config --cflags --libs gtk+-3.0`" + ], + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/Gtk3/gtk69_Ui3_test/.vscode/launch.json b/Gtk3/gtk69_Ui3_test/.vscode/launch.json new file mode 100644 index 0000000..6968827 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/.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/gtk69", + "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/Gtk3/gtk69_Ui3_test/.vscode/settings.json b/Gtk3/gtk69_Ui3_test/.vscode/settings.json new file mode 100644 index 0000000..0baae3a --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "C_Cpp.errorSquiggles": "Disabled", + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/Gtk3/gtk69_Ui3_test/.vscode/tasks.json b/Gtk3/gtk69_Ui3_test/.vscode/tasks.json new file mode 100644 index 0000000..a39cf85 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/.vscode/tasks.json @@ -0,0 +1,83 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-g", + "src/*.cpp", + "-o", + "${workspaceFolder}/bin/gtk69", + "-pthread", + //For Arm64 linux + /* + "-I/usr/lib/aarch64-linux-gnu/dbus-1.0/include", + "-I/usr/lib/aarch64-linux-gnu/glib-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", + */ + //Ubuntu and kali include paths + + //"-I/usr/include/uuid", + + //Manjaro linux and Arch linux include args + + "-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", + //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", + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} diff --git a/Gtk3/gtk69_Ui3_test/res/compile-resource.sh b/Gtk3/gtk69_Ui3_test/res/compile-resource.sh new file mode 100644 index 0000000..b41a7cc --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/compile-resource.sh @@ -0,0 +1 @@ + glib-compile-resources gtk69.gresource.xml --target=../src/resources.cpp --generate-source diff --git a/Gtk3/gtk69_Ui3_test/res/gtk69.gresource.xml b/Gtk3/gtk69_Ui3_test/res/gtk69.gresource.xml new file mode 100644 index 0000000..c78f191 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/gtk69.gresource.xml @@ -0,0 +1,16 @@ + + + + win1.ui + window.ui + winsize.ui + + + icons/16x16/actions/window-minimize.png + icons/16x16/actions/window-close.png + icons/48x48/actions/gtk69.png + icons/48x48/actions/win1.png + icons/48x48/actions/win1_running.png + icons/128x128/actions/gtk69.png + + \ No newline at end of file diff --git a/Gtk3/gtk69_Ui3_test/res/icons/128x128/actions/gtk69.png b/Gtk3/gtk69_Ui3_test/res/icons/128x128/actions/gtk69.png new file mode 100644 index 0000000..78a4acb Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/128x128/actions/gtk69.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-close.png b/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-close.png new file mode 100644 index 0000000..db9f61b Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-close.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-minimize.png b/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-minimize.png new file mode 100644 index 0000000..c1f38b7 Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/16x16/actions/window-minimize.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/gtk69.png b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/gtk69.png new file mode 100644 index 0000000..5b868e2 Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/gtk69.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1.png b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1.png new file mode 100644 index 0000000..8beb54e Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1_running.png b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1_running.png new file mode 100644 index 0000000..519b211 Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/res/icons/48x48/actions/win1_running.png differ diff --git a/Gtk3/gtk69_Ui3_test/res/win1.ui b/Gtk3/gtk69_Ui3_test/res/win1.ui new file mode 100644 index 0000000..b9353d5 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/win1.ui @@ -0,0 +1,63 @@ + + + + + + True + False + + + True + False + + + False + 440 + 250 + + + True + False + vertical + + + + + + + + + + + + + + True + False + window1 + False + + + True + True + True + image2 + none + + + + + True + True + True + image1 + none + + + 1 + + + + + + diff --git a/Gtk3/gtk69_Ui3_test/res/win1.ui~ b/Gtk3/gtk69_Ui3_test/res/win1.ui~ new file mode 100644 index 0000000..a35e989 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/win1.ui~ @@ -0,0 +1,63 @@ + + + + + + True + False + + + True + False + + + False + 200 + 200 + + + True + False + vertical + + + + + + + + + + + + + + True + False + window1 + False + + + True + True + True + image2 + none + + + + + True + True + True + image1 + none + + + 1 + + + + + + diff --git a/Gtk3/gtk69_Ui3_test/res/window.ui b/Gtk3/gtk69_Ui3_test/res/window.ui new file mode 100644 index 0000000..88ff096 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/window.ui @@ -0,0 +1,232 @@ + + + + + + False + 640 + 360 + + + True + False + + + True + False + + + -1 + + + + + + + True + False + + + False + + + 150 + 200 + True + True + left + True + + + True + False + vertical + + + Window1 + 150 + True + True + True + none + + + False + True + 0 + + + + + + True + True + True + none + + + False + True + 1 + + + + + + + + + + True + False + Apps + + + False + + + + + True + False + vertical + + + + + + + + + + + + 1 + + + + + True + False + Others + + + 1 + False + + + + + True + False + vertical + + + Window size config + True + True + True + none + + + False + True + 0 + + + + + Exit + True + True + True + none + + + False + True + 1 + + + + + + + + 2 + + + + + True + False + System + + + 2 + False + + + + + + + True + False + start + start + vertical + + + True + True + False + True + none + right + popover1 + + + True + False + + + + + False + True + 0 + + + + + True + True + True + image2 + none + + + False + True + 1 + + + + + True + True + True + none + + + False + True + 2 + + + + + + + diff --git a/Gtk3/gtk69_Ui3_test/res/window.ui~ b/Gtk3/gtk69_Ui3_test/res/window.ui~ new file mode 100644 index 0000000..080f459 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/window.ui~ @@ -0,0 +1,37 @@ + + + + + + False + 640 + 360 + + + True + False + + + True + False + + + -1 + + + + + + + True + False + gtk(69) + True + close,minimize,maximize:menu + + + + + + + diff --git a/Gtk3/gtk69_Ui3_test/res/winsize.ui b/Gtk3/gtk69_Ui3_test/res/winsize.ui new file mode 100644 index 0000000..3e638c9 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/winsize.ui @@ -0,0 +1,174 @@ + + + + + + 32767 + 1 + 10 + + + 32767 + 1 + 10 + + + False + dialog + + + False + vertical + 2 + + + False + end + + + Cancel + True + True + True + + + True + True + 0 + + + + + OK + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + + + True + False + Window Size: + + + False + True + 0 + + + + + True + True + 640 + number + adjustment1 + 640 + + + False + True + 1 + + + + + True + False + x + + + False + True + 2 + + + + + True + True + 360 + number + adjustment2 + True + 360 + + + False + True + 3 + + + + + False + True + 0 + + + + + True + False + + + + + + Use Default Size + True + True + True + + + False + True + 1 + + + + + Get Current Size + True + True + True + + + False + True + end + 2 + + + + + False + True + 2 + + + + + + button1 + button2 + + + diff --git a/Gtk3/gtk69_Ui3_test/res/winsize.ui~ b/Gtk3/gtk69_Ui3_test/res/winsize.ui~ new file mode 100644 index 0000000..333a392 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/res/winsize.ui~ @@ -0,0 +1,170 @@ + + + + + + 32767 + 1 + 10 + + + 32767 + 1 + 10 + + + False + dialog + + + False + vertical + 2 + + + False + end + + + Cancel + True + True + True + + + True + True + 0 + + + + + OK + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + + + True + False + Window Size: + + + False + True + 0 + + + + + True + True + 640 + number + adjustment1 + 640 + + + False + True + 1 + + + + + True + False + x + + + False + True + 2 + + + + + True + True + 360 + number + adjustment2 + True + 360 + + + False + True + 3 + + + + + False + True + 0 + + + + + True + False + + + + + + Use Default Size + True + True + True + + + False + True + 1 + + + + + Get Current Size + True + True + True + + + False + True + end + 2 + + + + + False + True + 2 + + + + + + diff --git a/Gtk3/gtk69_Ui3_test/src/main.cpp b/Gtk3/gtk69_Ui3_test/src/main.cpp new file mode 100644 index 0000000..699f37b --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/src/main.cpp @@ -0,0 +1,120 @@ +#include +#include "winconf.h" +#include "img7.xpm" + +static GtkWidget *window1=NULL,*win1_image; + +static void win1_destroy(GtkWidget *widget,gpointer data){ + gtk_widget_destroy(window1); + window1=NULL; + //GtkWidget *image=(GtkWidget*)gtk_builder_get_object(panel2,"image2"); + gtk_image_set_from_icon_name((GtkImage*)win1_image,"win1",GTK_ICON_SIZE_BUTTON); +} + +static GtkWidget *win1_init(GtkWindow *parent){ + //Initalize window1 + GtkWidget *win1,*btn_mini,*btn_close,*img_mini,*img_close; + GtkBuilder *builder=gtk_builder_new_from_resource("/gtk69/win1.ui"); + win1=(GtkWidget*)gtk_builder_get_object(builder,"win1"); + gtk_window_set_transient_for((GtkWindow*)win1,parent); + img_mini=(GtkWidget*)gtk_builder_get_object(builder,"image1"); + gtk_image_set_from_icon_name(GTK_IMAGE(img_mini),"window-minimize",GTK_ICON_SIZE_BUTTON); + btn_mini=(GtkWidget*)gtk_builder_get_object(builder,"btn_mini"); + g_signal_connect_swapped(btn_mini,"clicked",G_CALLBACK(gtk_widget_hide),win1); + img_close=(GtkWidget*)gtk_builder_get_object(builder,"image2"); + gtk_image_set_from_icon_name(GTK_IMAGE(img_close),"window-close",GTK_ICON_SIZE_BUTTON); + btn_close=(GtkWidget*)gtk_builder_get_object(builder,"btn_close"); + g_signal_connect(btn_close,"clicked",G_CALLBACK(win1_destroy),win1); + g_object_unref(builder); + return win1; +} + +static void win1_activate(GtkWidget *widget,GtkBuilder *builder){ + //The Open button for win1 + GtkWindow *win_1=(GtkWindow*)gtk_builder_get_object(builder,"window"); + if(window1==NULL){ + window1=win1_init(win_1); + gtk_window_set_icon_name((GtkWindow*)window1,"win1"); + win1_image=(GtkWidget*)gtk_builder_get_object(builder,"image2"); + gtk_image_set_from_icon_name((GtkImage*)win1_image,"win1_running",GTK_ICON_SIZE_BUTTON); + gtk_widget_show_all(window1); + g_signal_connect(window1,"destroy",G_CALLBACK(win1_destroy),NULL); + } +} + +static void win1_ctrl(GtkWidget *widget,GtkBuilder *builder){ + //The Control button for win on taskbar + GtkWindow *win_2=(GtkWindow*)gtk_builder_get_object(builder,"window"); + if(window1==NULL){ + win1_image=(GtkWidget*)gtk_builder_get_object(builder,"image2"); + window1=win1_init(win_2); + gtk_widget_show_all(window1); + gtk_image_set_from_icon_name((GtkImage*)win1_image,"win1_running",GTK_ICON_SIZE_BUTTON); + g_signal_connect(window1,"destroy",G_CALLBACK(win1_destroy),NULL); + }else{ + gboolean is_show=gtk_widget_get_visible(window1); + if(is_show==TRUE) gtk_widget_hide(window1); + else gtk_widget_show_all(window1); + } +} + +static void set_background(GtkWidget *back,int width,int height){ + //Set a background for window + GdkPixbuf *pixbuf=gdk_pixbuf_new_from_xpm_data(img7); + GdkPixbuf *sized=gdk_pixbuf_scale_simple(pixbuf,width,height,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf((GtkImage*)back,sized); + g_object_unref(pixbuf); + g_object_unref(sized); +} + +static void add_panel(GtkWidget *overlay,GtkBuilder *builder){ + GtkWindow *win=(GtkWindow*)gtk_builder_get_object(builder,"window"); + GtkWidget *panel1,*img_panel,*img_win1,*btn_win1,*panel_win1,*btn_size,*btn_exit; + //Get Panel1 and add the panel to window + panel1=(GtkWidget*)gtk_builder_get_object(builder,"panelbox"); + //Main panel button + img_panel=(GtkWidget*)gtk_builder_get_object(builder,"image1"); + gtk_image_set_from_icon_name(GTK_IMAGE(img_panel),"gtk69",GTK_ICON_SIZE_BUTTON); + //Window1 button on menu and panel + img_win1=(GtkWidget*)gtk_builder_get_object(builder,"image2"); + gtk_image_set_from_icon_name(GTK_IMAGE(img_win1),"win1",GTK_ICON_SIZE_BUTTON); + panel_win1=(GtkWidget*)gtk_builder_get_object(builder,"panel_win1"); + btn_win1=(GtkWidget*)gtk_builder_get_object(builder,"btn_win1"); + g_signal_connect(panel_win1,"clicked",G_CALLBACK(win1_ctrl),builder); + g_signal_connect(btn_win1,"clicked",G_CALLBACK(win1_activate),builder); + //Window Size config + btn_size=(GtkWidget*)gtk_builder_get_object(builder,"btnsize"); + g_signal_connect(btn_size,"clicked",G_CALLBACK(conf_dialog),win); + //Exit + btn_exit=(GtkWidget*)gtk_builder_get_object(builder,"btnExit"); + g_signal_connect_swapped(btn_exit,"clicked",G_CALLBACK(gtk_widget_destroy),win); + gtk_widget_set_halign(panel1,GTK_ALIGN_START); + gtk_widget_set_valign(panel1,GTK_ALIGN_START); + gtk_overlay_add_overlay((GtkOverlay*)overlay,panel1); +} + +static void gtkmain(GtkApplication *app,gpointer user_data){ + GtkBuilder *builder=gtk_builder_new_from_resource("/gtk69/window.ui"); + GtkWidget *window,*background,*overlay; + int width=640,height=360; + get_config(&width,&height); + //Get Objects and initalize window + window=(GtkWidget*)gtk_builder_get_object(builder,"window"); + gtk_window_set_icon_name(GTK_WINDOW(window),"gtk69"); + gtk_window_set_default_size(GTK_WINDOW(window),width,height); + //Background + background=(GtkWidget*)gtk_builder_get_object(builder,"background"); + set_background(background,width,height); + //Add panel + overlay=(GtkWidget*)gtk_builder_get_object(builder,"overlay"); + add_panel(overlay,builder); + gtk_application_add_window(app,GTK_WINDOW(window)); + gtk_widget_show_all(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); +} diff --git a/Gtk3/gtk69_Ui3_test/src/public_src_img7_xpm b/Gtk3/gtk69_Ui3_test/src/public_src_img7_xpm new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/src/public_src_img7_xpm @@ -0,0 +1 @@ + diff --git a/Gtk3/gtk69_Ui3_test/src/resources.7z b/Gtk3/gtk69_Ui3_test/src/resources.7z new file mode 100644 index 0000000..6c082ae Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/src/resources.7z differ diff --git a/Gtk3/gtk69_Ui3_test/src/winconf.cpp b/Gtk3/gtk69_Ui3_test/src/winconf.cpp new file mode 100644 index 0000000..d438d8f --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/src/winconf.cpp @@ -0,0 +1,72 @@ +#include +#include "winconf.h" + +void conf_dialog(GtkWidget *widget,GtkWindow *win){ + //Window config dialog + GtkBuilder *conf_size=gtk_builder_new_from_resource("/gtk69/winsize.ui"); + GObject *dialog=gtk_builder_get_object(conf_size,"dialog"); + gtk_window_set_transient_for(GTK_WINDOW(dialog),win); + g_signal_connect(dialog,"response",G_CALLBACK(conf_response),conf_size); + //Set default config + GtkWidget *btn_width,*btn_height; + btn_width=(GtkWidget*)gtk_builder_get_object(conf_size,"btn_width"); + gtk_spin_button_set_value((GtkSpinButton*)btn_width,640.0); + btn_height=(GtkWidget*)gtk_builder_get_object(conf_size,"btn_height"); + gtk_spin_button_set_value((GtkSpinButton*)btn_height,360.0); + //Get window size + GObject *btnGet=gtk_builder_get_object(conf_size,"btnGet"); + g_signal_connect(btnGet,"clicked",G_CALLBACK(get_winsize),conf_size); + //Reset to default + GObject *btn_default=gtk_builder_get_object(conf_size,"btn_default"); + g_signal_connect(btn_default,"clicked",G_CALLBACK(set_default),conf_size); + gtk_widget_show_all(GTK_WIDGET(dialog)); +} + +void conf_response(GtkWidget *widget,int response,GtkBuilder *builder_conf){ + //Get width and height config and put the numbers into winsize.conf file + GtkWidget *btn_width,*btn_height; + btn_width=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_width"); + btn_height=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_height"); + if(response==GTK_RESPONSE_OK){ + int width,height; + width=gtk_spin_button_get_value_as_int((GtkSpinButton*)btn_width); + height=gtk_spin_button_get_value_as_int((GtkSpinButton*)btn_height); + freopen("winsize.conf","w",stdout); + g_print("%d %d",width,height); + fclose(stdout); + } + gtk_widget_destroy(widget); +} + +void set_default(GtkWidget *widget,GtkBuilder *builder_conf){ + //Discard changes and set to default config + GtkWidget *btn_width,*btn_height; + btn_width=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_width"); + gtk_spin_button_set_value((GtkSpinButton*)btn_width,640.0); + btn_height=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_height"); + gtk_spin_button_set_value((GtkSpinButton*)btn_height,360.0); +} + +void get_winsize(GtkWidget *widget,GtkBuilder *builder_conf){ + //Get current window size + int width=640,height=360; + GtkWindow *window; + //Get dialog window and entry + GObject *dialog=gtk_builder_get_object(builder_conf,"dialog"); + GtkWidget *btn_width,*btn_height; + btn_width=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_width"); + btn_height=(GtkWidget*)gtk_builder_get_object(builder_conf,"btn_height"); + //Get main window + window=gtk_window_get_transient_for(GTK_WINDOW(dialog)); + gtk_window_get_size(GTK_WINDOW(window),&width,&height); + //g_print("%d %d\n",width,height); + gtk_spin_button_set_value((GtkSpinButton*)btn_width,width); + gtk_spin_button_set_value((GtkSpinButton*)btn_height,height); +} + +void get_config(int *width,int *height){ + freopen("winsize.conf","r",stdin); + scanf("%d",width); + scanf("%d",height); + fclose(stdin); +} diff --git a/Gtk3/gtk69_Ui3_test/src/winconf.h b/Gtk3/gtk69_Ui3_test/src/winconf.h new file mode 100644 index 0000000..eb6a222 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/src/winconf.h @@ -0,0 +1,17 @@ +#ifndef __WIN_CONF_H_ +#define __WIN_CONF_H_ + +#include + +void conf_dialog(GtkWidget *widget,GtkWindow *win); + +void conf_response(GtkWidget *widget,int response,GtkBuilder *builder_conf); + +void set_default(GtkWidget *widget,GtkBuilder *builder_conf); + +void get_winsize(GtkWidget *widget,GtkBuilder *buider_conf); + +void get_config(int *width,int *height); + + +#endif diff --git a/Gtk3/gtk69_Ui3_test/win1.xcf b/Gtk3/gtk69_Ui3_test/win1.xcf new file mode 100644 index 0000000..54f5415 Binary files /dev/null and b/Gtk3/gtk69_Ui3_test/win1.xcf differ diff --git a/Gtk3/gtk69_Ui3_test/winsize.conf b/Gtk3/gtk69_Ui3_test/winsize.conf new file mode 100644 index 0000000..906ec34 --- /dev/null +++ b/Gtk3/gtk69_Ui3_test/winsize.conf @@ -0,0 +1 @@ +878 552 \ No newline at end of file diff --git a/Gtk3/public_src/img7.7z b/Gtk3/public_src/img7.7z new file mode 100644 index 0000000..82bb53f Binary files /dev/null and b/Gtk3/public_src/img7.7z differ