diff --git a/Gtkmm3/.vscode/c_cpp_properties.json b/Gtkmm3/.vscode/c_cpp_properties.json index 99fbbb6..1e4207f 100644 --- a/Gtkmm3/.vscode/c_cpp_properties.json +++ b/Gtkmm3/.vscode/c_cpp_properties.json @@ -8,12 +8,26 @@ //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/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/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 /* @@ -26,6 +40,7 @@ "/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/**", @@ -42,17 +57,136 @@ "/usr/include/gdk-pixbuf-2.0/**", "/usr/include/libmount/**", "/usr/include/blkid/**", - "/usr/include/glib-2.0/**" + "/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++14", - "intelliSenseMode": "gcc-arm64", + "cppStandard": "gnu++17", + "intelliSenseMode": "gcc-x64", "compilerArgs": [ - "`pkg-config --cflags --libs gtk+-3.0`" + "`pkg-config --cflags --libs gtkmm-3.0`" ], "configurationProvider": "ms-vscode.cmake-tools" + }, + { + "name": "win32", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/src/**", + //I assume the msys2 installed in D:/msys64 + "D:/msys64/mingw64/include/gtkmm-3.0/**", + "D:/msys64/mingw64/lib/gtkmm-3.0/include/**", + "D:/msys64/mingw64/include/giomm-2.4/**", + "D:/msys64/mingw64/lib/giomm-2.4/include/**", + "D:/msys64/mingw64/include/**", + "D:/msys64/mingw64/include/glib-2.0/**", + "D:/msys64/mingw64/lib/glib-2.0/include/**", + "D:/msys64/mingw64/include/glibmm-2.4/**", + "D:/msys64/mingw64/lib/glibmm-2.4/include/**", + "D:/msys64/mingw64/include/sigc++-2.0/**", + "D:/msys64/mingw64/lib/sigc++-2.0/include/**", + "D:/msys64/mingw64/include/gtk-3.0/**", + "D:/msys64/mingw64/include/pango-1.0/**", + "D:/msys64/mingw64/include/harfbuzz/**", + "D:/msys64/mingw64/include/freetype2/**", + "D:/msys64/mingw64/include/libpng16/**", + "D:/msys64/mingw64/include/fribidi/**", + "D:/msys64/mingw64/include/cairo/**", + "D:/msys64/mingw64/include/lzo/**", + "D:/msys64/mingw64/include/pixman-1/**", + "D:/msys64/mingw64/include/gdk-pixbuf-2.0", + "D:/msys64/mingw64/include/atk-1.0", + "D:/msys64/mingw64/include/cairomm-1.0/**", + "D:/msys64/mingw64/lib/cairomm-1.0/include/**", + "D:/msys64/mingw64/include/pangomm-1.4/**", + "D:/msys64/mingw64/lib/pangomm-1.4/include/**" + ], + "defines": [], + "compilerPath": "D:/msys64/MinGW64/bin/gcc.exe", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-gcc-x64" + }, + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**", + "/usr/local/Cellar/libffi/3.3_3/include/**", + "/usr/local/Cellar/gtkmm3/3.24.4/include/gtkmm-3.0/**", + "/usr/local/Cellar/gtkmm3/3.24.4/lib/gtkmm-3.0/include", + "/usr/local/Cellar/atkmm@2.28/2.28.1_1/include/atkmm-1.6/**", + "/usr/local/Cellar/atkmm@2.28/2.28.1_1/lib/atkmm-1.6/include/**", + "/usr/local/Cellar/gtk+3/3.24.29/include/gtk-3.0/unix-print/**", + "/usr/local/Cellar/gtkmm3/3.24.4/include/gdkmm-3.0/**", + "/usr/local/Cellar/gtkmm3/3.24.4/lib/gdkmm-3.0/include/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/include/giomm-2.4/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/lib/giomm-2.4/include/**", + "/usr/local/Cellar/pangomm@2.46/2.46.0/include/pangomm-1.4/**", + "/usr/local/Cellar/pangomm@2.46/2.46.0/lib/pangomm-1.4/include/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/include/glibmm-2.4/**", + "/usr/local/Cellar/glibmm@2.66/2.66.0/lib/glibmm-2.4/include/**", + "/usr/local/Cellar/cairomm@1.14/1.14.2/include/cairomm-1.0/**", + "/usr/local/Cellar/cairomm@1.14/1.14.2/lib/cairomm-1.0/include/**", + "/usr/local/Cellar/libsigc++@2/2.10.6/include/sigc++-2.0/**", + "/usr/local/Cellar/libsigc++@2/2.10.6/lib/sigc++-2.0/include/**", + "/usr/local/Cellar/gtk+3/3.24.29/include/gtk-3.0/**", + "/usr/local/Cellar/glib/2.68.2/include/gio-unix-2.0/**", + "/usr/local/Cellar/cairo/1.16.0_5/include/cairo/**", + "/usr/local/Cellar/libepoxy/1.5.7/include/**", + "/usr/local/Cellar/pango/1.48.4/include/pango-1.0", + "/usr/local/Cellar/harfbuzz/2.8.1/include/harfbuzz", + "/usr/local/Cellar/pango/1.48.4/include/pango-1.0/**", + "/usr/local/Cellar/fribidi/1.0.10/include/fribidi/**", + "/usr/local/Cellar/harfbuzz/2.8.1/include/harfbuzz/**", + "/usr/local/Cellar/graphite2/1.3.14/include/**", + "/usr/local/Cellar/atk/2.36.0/include/atk-1.0/**", + "/usr/local/Cellar/cairo/1.16.0_5/include/cairo/**", + "/usr/local/Cellar/pixman/0.40.0/include/pixman-1/**", + "/usr/local/Cellar/fontconfig/2.13.1/include/**", + "/usr/local/opt/freetype/include/freetype2/**", + "/usr/local/Cellar/libpng/1.6.37/include/libpng16/**", + "/usr/local/Cellar/libxcb/1.14_1/include/**", + "/usr/local/Cellar/libxrender/0.9.10/include/**", + "/usr/local/Cellar/libxext/1.3.4/include/**", + "/usr/local/Cellar/libx11/1.7.0/include/**", + "/usr/local/Cellar/libxcb/1.14_1/include/**", + "/usr/local/Cellar/libxau/1.0.9/include/**", + "/usr/local/Cellar/libxdmcp/1.1.3/include/**", + "/usr/local/Cellar/gdk-pixbuf/2.42.6/include/gdk-pixbuf-2.0/**", + "/usr/local/Cellar/libpng/1.6.37/include/libpng16/**", + "/usr/local/Cellar/libtiff/4.3.0/include/**", + "/usr/local/Cellar/glib/2.68.2/include/**", + "/usr/local/Cellar/glib/2.68.2/include/glib-2.0/**", + "/usr/local/Cellar/glib/2.68.2/lib/glib-2.0/include/**", + "/usr/local/opt/gettext/include/**", + "/usr/local/Cellar/pcre/8.44/include/**", + "/usr/local/Cellar/xorgproto/2021.4/include/**" + ], + "defines": [], + "macFrameworkPath": [], + "compilerPath": "/usr/local/bin/gcc-11", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "macos-gcc-x64" } ], "version": 4 diff --git a/Gtkmm3/.vscode/settings.json b/Gtkmm3/.vscode/settings.json index 0baae3a..208afcc 100644 --- a/Gtkmm3/.vscode/settings.json +++ b/Gtkmm3/.vscode/settings.json @@ -1,4 +1,5 @@ { "C_Cpp.errorSquiggles": "Disabled", - "cmake.configureOnOpen": false + "cmake.configureOnOpen": false, + "C_Cpp.dimInactiveRegions": false } \ No newline at end of file diff --git a/Gtkmm3/CMakeLists.txt b/Gtkmm3/CMakeLists.txt index 8558a36..b487966 100644 --- a/Gtkmm3/CMakeLists.txt +++ b/Gtkmm3/CMakeLists.txt @@ -1,6 +1,6 @@ set(CMAKE_CXX_STANDARD 17) cmake_minimum_required(VERSION 3.0.0) -project(gtk84 VERSION 0.1.0) +project(My_GtkUI VERSION 3.0.0) include(CTest) enable_testing() @@ -9,11 +9,13 @@ set(CPACK_PROJECT_NAME ${PROJECT_NAME}) set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) include(CPack) +include_directories(.) +include_directories(..) find_package (PkgConfig REQUIRED) pkg_check_modules (GTKMM3 REQUIRED gtkmm-3.0) include_directories (${GTKMM3_INCLUDE_DIRS}) link_directories (${GTKMM3_LIBRARY_DIRS}) -add_executable(gtk84 src/main.cc src/MyWin.cc) +add_executable(My_GtkUI src/main.cc src/MyWin.cc src/MyStack.cc) add_definitions (${GTKMM3_CFLAGS_OTHER}) target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES}) diff --git a/Gtkmm3/build_mingw.cmd b/Gtkmm3/build_mingw.cmd index 187d448..092c16d 100644 --- a/Gtkmm3/build_mingw.cmd +++ b/Gtkmm3/build_mingw.cmd @@ -1,3 +1,3 @@ cd build_mingw mingw32-make -gtk84 \ No newline at end of file +gtk85 diff --git a/Gtkmm3/res/appmenu.xml b/Gtkmm3/res/appmenu.xml new file mode 100644 index 0000000..53c2fc6 --- /dev/null +++ b/Gtkmm3/res/appmenu.xml @@ -0,0 +1,23 @@ + + + +
+ + Change background + win.back + + + Default background + win.default + + + About + win.about + + + Exit + win.quit + +
+
+
\ No newline at end of file diff --git a/Gtkmm3/res/game1.ui~ b/Gtkmm3/res/game1.ui~ deleted file mode 100644 index 3c5b9cc..0000000 --- a/Gtkmm3/res/game1.ui~ +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - False - 15 - gtk31-guess - True - - - - True - False - - - True - False - Select a button - - - 1 - 0 - 3 - - - - - 1 - 100 - 100 - True - True - True - top - - - 1 - 2 - - - - - 2 - 100 - 100 - True - True - True - top - - - 3 - 2 - - - - - 3 - 100 - 100 - True - True - True - top - - - 1 - 4 - - - - - 4 - 100 - 100 - True - True - True - top - - - 3 - 4 - - - - - Go - True - True - True - - - 1 - 6 - - - - - Exit - True - True - True - - - 3 - 6 - - - - - 20 - 20 - True - False - - - 2 - 3 - - - - - 20 - 20 - True - False - - - 2 - 5 - - - - - 20 - 20 - True - False - - - 2 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Gtkmm3/res/leftpanel.ui~ b/Gtkmm3/res/leftpanel.ui~ deleted file mode 100644 index 43037fe..0000000 --- a/Gtkmm3/res/leftpanel.ui~ +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - True - False - - - True - False - - - 300 - 400 - False - False - - - True - True - left - True - - - True - False - vertical - - - audacious - True - True - True - none - True - - - False - True - 0 - - - - - Gedit Text Editor - True - True - True - image2 - none - True - - - False - True - 1 - - - - - VLC Media Player - True - True - True - image1 - none - True - - - False - True - 2 - - - - - - - - - - - - - True - False - Applications (Linux) - - - False - - - - - True - False - vertical - - - VLC Media Player - True - True - True - none - True - - - False - True - 0 - - - - - Notepad - True - True - True - none - True - - - False - True - 1 - - - - - - - - - - - - - - 1 - - - - - True - False - Applications (Win32) - - - 1 - False - - - - - True - False - vertical - - - Guess Game - True - True - True - none - - - False - True - 0 - - - - - About - True - True - True - image3 - none - - - False - True - 1 - - - - - - - - - - - - - - 2 - - - - - True - False - General Apps - - - 2 - False - - - - - - - True - False - vertical - 5 - start - - - True - True - False - True - none - right - popover1 - - - True - False - start-here - - - - - True - True - 0 - True - - - - - - - - - - - True - False - gtk-about - - diff --git a/Gtkmm3/res/main_stack.ui b/Gtkmm3/res/main_stack.ui new file mode 100644 index 0000000..f54a5b2 --- /dev/null +++ b/Gtkmm3/res/main_stack.ui @@ -0,0 +1,89 @@ + + + + + + True + False + 400 + under-up + + + True + False + + + + + + page0 + page0 + + + + + True + False + + + True + False + Welcome! + + + -1 + + + + + page1 + page1 + 1 + + + + + True + False + center + center + vertical + + + True + False + + + False + True + 0 + + + + + True + False + dale + + + False + True + 1 + + + + + login + True + True + True + none + + + False + True + 2 + + + + diff --git a/Gtkmm3/res/title.ui~ b/Gtkmm3/res/title.ui~ deleted file mode 100644 index b7cb142..0000000 --- a/Gtkmm3/res/title.ui~ +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - True - False - start - - - True - False - Gtk42 Desktop - - - True - True - 0 - - - - - - - - - - diff --git a/Gtkmm3/res/toppanel.ui~ b/Gtkmm3/res/toppanel.ui~ deleted file mode 100644 index 1ee1603..0000000 --- a/Gtkmm3/res/toppanel.ui~ +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - True - False - ac-adapter-symbolic - - - True - False - system-help - - - True - False - - - True - False - - - True - False - - - False - - - True - False - vertical - 5 - start - - - Change back - True - True - True - image3 - none - - - True - True - 1 - - - - - Win Settings - True - True - True - image5 - none - - - True - True - 3 - - - - - Exit mainwin - True - True - True - image4 - none - - - True - True - 5 - - - - - - - True - False - end - - - - - - - - - - - - - - - - - - True - False - 20:00 2021/2/14 - - - True - True - 5 - - - - - True - True - True - image2 - none - - - True - True - 6 - True - - - - - True - True - True - image1 - none - - - True - True - 7 - True - - - - - True - True - False - True - none - vertical - audio-volume-muted-symbolic -audio-volume-high-symbolic -audio-volume-low-symbolic -audio-volume-medium-symbolic - - - False - False - - - - - False - False - - - - - True - True - 8 - True - - - - - True - True - False - True - none - popover1 - - - - - - True - True - 9 - True - - - - diff --git a/Gtkmm3/res/win1.ui b/Gtkmm3/res/win1.ui deleted file mode 100644 index a6f5b50..0000000 --- a/Gtkmm3/res/win1.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - False - dialog - Gtk Ui - 2.0 - 2020-2021 Xe Corporation - github.com/daleclack - Dale - org.gtk.daleclack - - - False - vertical - 2 - - - False - end - - - False - False - 0 - - - - - - - - - diff --git a/Gtkmm3/res/win1.ui~ b/Gtkmm3/res/win1.ui~ deleted file mode 100644 index a6f5b50..0000000 --- a/Gtkmm3/res/win1.ui~ +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - False - dialog - Gtk Ui - 2.0 - 2020-2021 Xe Corporation - github.com/daleclack - Dale - org.gtk.daleclack - - - False - vertical - 2 - - - False - end - - - False - False - 0 - - - - - - - - - diff --git a/Gtkmm3/res/win_size.ui~ b/Gtkmm3/res/win_size.ui~ deleted file mode 100644 index de5bdc3..0000000 --- a/Gtkmm3/res/win_size.ui~ +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - False - Window size config - 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 - Input window size - - - False - True - 0 - - - - - True - False - - - True - True - - - False - True - 0 - - - - - True - False - x - - - False - True - 1 - - - - - True - True - - - False - True - 2 - - - - - Get size - True - True - True - - - False - True - 3 - - - - - False - True - 2 - - - - - True - False - end - - - - - - - - - Use default config - True - True - True - - - True - True - 2 - - - - - False - True - 3 - - - - - - btncancel - btnok - - - diff --git a/Gtkmm3/res/window.ui b/Gtkmm3/res/window.ui deleted file mode 100644 index 1012dc7..0000000 --- a/Gtkmm3/res/window.ui +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - True - False - user-home - - - False - gtk(42) - 640 - 360 - True - gtk4-icon - - - True - False - - - 100 - 80 - True - False - gtk-missing-image - - - - - Home - 100 - 80 - True - True - True - image1 - none - top - True - - - 70 - 30 - - - - - - diff --git a/Gtkmm3/res/window.ui~ b/Gtkmm3/res/window.ui~ deleted file mode 100644 index 1012dc7..0000000 --- a/Gtkmm3/res/window.ui~ +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - True - False - user-home - - - False - gtk(42) - 640 - 360 - True - gtk4-icon - - - True - False - - - 100 - 80 - True - False - gtk-missing-image - - - - - Home - 100 - 80 - True - True - True - image1 - none - top - True - - - 70 - 30 - - - - - - diff --git a/Gtkmm3/resources(expand to src Folder).7z b/Gtkmm3/resources(expand to src Folder).7z deleted file mode 100644 index 91aa9b4..0000000 Binary files a/Gtkmm3/resources(expand to src Folder).7z and /dev/null differ diff --git a/Gtkmm3/src/MyStack.cc b/Gtkmm3/src/MyStack.cc new file mode 100644 index 0000000..b7c0e5a --- /dev/null +++ b/Gtkmm3/src/MyStack.cc @@ -0,0 +1,21 @@ +#include "MyStack.hh" + +MyStack::MyStack(){ + //Create a builder + ref_builder=Gtk::Builder::create_from_file("../res/main_stack.ui"); + //Get widgets + ref_builder->get_widget("main_stack",stack); + ref_builder->get_widget("login_overlay",login_overlay); + ref_builder->get_widget("user_box",user_box); + ref_builder->get_widget("user_image",user_image); + ref_builder->get_widget("login_btn",login_btn); + ref_builder->get_widget("main_overlay",main_overlay); + //Initalize Interface + user_image->set_from_icon_name("org.gtk.daleclack",Gtk::ICON_SIZE_DIALOG); + login_btn->signal_clicked().connect(sigc::mem_fun(*this,&MyStack::btnlogin_clicked)); + login_overlay->add_overlay(*user_box); +} + +void MyStack::btnlogin_clicked(){ + stack->set_visible_child(*main_overlay); +} \ No newline at end of file diff --git a/Gtkmm3/src/MyStack.hh b/Gtkmm3/src/MyStack.hh new file mode 100644 index 0000000..8a98cf0 --- /dev/null +++ b/Gtkmm3/src/MyStack.hh @@ -0,0 +1,19 @@ +#pragma once + +#include + +class MyStack{ +public: + MyStack(); + Gtk::Stack *stack; +private: + //Main builder + Glib::RefPtr ref_builder; + //Child widgets + Gtk::Overlay *main_overlay,*login_overlay; + Gtk::Box *user_box; + Gtk::Image *user_image; + Gtk::Button *login_btn; + //Signal Handlers + void btnlogin_clicked(); +}; diff --git a/Gtkmm3/src/MyWin.cc b/Gtkmm3/src/MyWin.cc new file mode 100644 index 0000000..34ccc40 --- /dev/null +++ b/Gtkmm3/src/MyWin.cc @@ -0,0 +1,129 @@ +#include "MyWin.hh" +#include "winpe.xpm" + +MyWin::MyWin(): +main_box(Gtk::ORIENTATION_VERTICAL) +{ + //Initalize Window + set_icon_name("org.gtk.daleclack"); + set_default_size(800,450); + overlay.add_overlay(draw_area); + default_background(); + overlay.add(background); + + //Initalize menu + menu_builder=Gtk::Builder::create_from_file("../res/appmenu.xml"); + auto object=menu_builder->get_object("app-menu"); + auto gmenu=Glib::RefPtr::cast_dynamic(object); + + //Menu actions + add_action("quit",sigc::mem_fun(*this,&MyWin::win_quit)); + add_action("default",sigc::mem_fun(*this,&MyWin::default_background)); + add_action("back",sigc::mem_fun(*this,&MyWin::back_dialog)); + add_action("about",sigc::mem_fun(*this,&MyWin::about_dialog)); + + //Set Popover Menu + popover.bind_model(gmenu); + popover.set_relative_to(draw_area); + + //Set Gesture + gesture=Gtk::GestureMultiPress::create(overlay); + gesture->set_button(GDK_BUTTON_SECONDARY); + gesture->signal_pressed().connect(sigc::mem_fun(*this,&MyWin::btn_pressed)); + + //Add Toppanel + + //Add Stack + main_box.pack_start(*(main_stack.stack)); + overlay.add_overlay(main_box); + + //Add Overlay to window and show everything + add(overlay); + show_all(); +} + +void MyWin::btn_pressed(int n_press,double x,double y){ + //When mouse pressed,show a menu + Gdk::Rectangle point{(int)x,(int)y,1,1}; + popover.set_pointing_to(point); + popover.popup(); +} + +void MyWin::default_background(){ + //Default background + Glib::RefPtr pixbuf=Gdk::Pixbuf::create_from_xpm_data(winpe); + Glib::RefPtr sized=pixbuf->scale_simple(800,450,Gdk::INTERP_BILINEAR); + gtk_image_set_from_pixbuf(background.gobj(),sized->gobj()); + + //Free Memory of pixbufs + pixbuf.reset(); + sized.reset(); +} + +void MyWin::back_dialog(){ + //Initalize dialog + auto dialog=new Gtk::FileChooserDialog("Open Image File", + Gtk::FILE_CHOOSER_ACTION_OPEN); + dialog->set_transient_for(*this); + dialog->signal_response().connect(sigc::bind( + sigc::mem_fun(*this,&MyWin::change_background),dialog)); + //Add button for dialog + dialog->add_button("OK",Gtk::RESPONSE_OK); + dialog->add_button("Cancel",Gtk::RESPONSE_CANCEL); + //Add Filter + auto filter=Gtk::FileFilter::create(); + filter->set_name("Image Files"); + filter->add_mime_type("image/*"); + dialog->add_filter(filter); + + auto filter2=Gtk::FileFilter::create(); + filter2->set_name("All Files"); + filter2->add_pattern("*"); + dialog->add_filter(filter2); + + dialog->show_all(); + filter.reset(); + filter2.reset(); +} + +void MyWin::change_background(int response,Gtk::FileChooserDialog *dialog){ + Glib::ustring filename; + if(response==Gtk::RESPONSE_OK){ + filename=dialog->get_filename(); + //Default background + Glib::RefPtr pixbuf=Gdk::Pixbuf::create_from_file(filename.c_str()); + Glib::RefPtr sized=pixbuf->scale_simple(800,450,Gdk::INTERP_BILINEAR); + gtk_image_set_from_pixbuf(background.gobj(),sized->gobj()); + + //Free Memory of pixbufs + pixbuf.reset(); + sized.reset(); + } + delete dialog; +} + +void MyWin::about_dialog(){ + char *version; + Gtk::AboutDialog about_dialog(true); + about_dialog.set_transient_for(*this); + //Create Comments + version=g_strdup_printf("3.0\nRunning against Gtkmm %d.%d.%d", + GTKMM_MAJOR_VERSION, + GTKMM_MINOR_VERSION, + GTKMM_MICRO_VERSION); + about_dialog.set_program_name("My Gtk UI"); + about_dialog.set_version(version); + about_dialog.set_logo_icon_name("org.gtk.daleclack"); + about_dialog.set_copyright("© 2019—2021 The Xe Project"); + about_dialog.set_comments("A test program for menu and background in gtkmm"); + about_dialog.set_title("About Gtk UI"); + about_dialog.run(); + g_free(version); +} + +void MyWin::win_quit(){ + hide(); +} + +MyWin::~MyWin(){ +} diff --git a/Gtkmm3/src/MyWin.hh b/Gtkmm3/src/MyWin.hh new file mode 100644 index 0000000..fd4704c --- /dev/null +++ b/Gtkmm3/src/MyWin.hh @@ -0,0 +1,32 @@ +#pragma once + +#include +#include "MyStack.hh" + +class MyWin : public Gtk::ApplicationWindow{ +public: + MyWin(); + virtual ~MyWin(); +private: + //Child widgets + Glib::RefPtr menu_builder; + Gtk::Overlay overlay; + Gtk::DrawingArea draw_area; + Gtk::Box main_box; + Gtk::PopoverMenu popover; + Gtk::Image background; + + //Main Pages + MyStack main_stack; + + //Gesture Widgets + Glib::RefPtr gesture; + void btn_pressed(int n_press,double x,double y); + + //Signal Handlers + void default_background(); + void back_dialog(); + void change_background(int response,Gtk::FileChooserDialog *dialog); + void about_dialog(); + void win_quit(); +}; \ No newline at end of file diff --git a/Gtkmm3/src/main.cc b/Gtkmm3/src/main.cc new file mode 100644 index 0000000..0c49a3a --- /dev/null +++ b/Gtkmm3/src/main.cc @@ -0,0 +1,7 @@ +#include "MyWin.hh" + +int main(int argc,char **argv){ + auto app=Gtk::Application::create(argc,argv,"org.gtk.daleclack"); + MyWin window; + return app->run(window); +} \ No newline at end of file