diff --git a/Gtk3/gtk89_css_test/CMakeLists.txt b/Gtk3/gtk89_css_test/CMakeLists.txt new file mode 100644 index 0000000..04869f3 --- /dev/null +++ b/Gtk3/gtk89_css_test/CMakeLists.txt @@ -0,0 +1,19 @@ +set(CMAKE_CXX_STANDARD 17) +cmake_minimum_required(VERSION 3.0.0) +project(gtk89 VERSION 0.1.0) + +include(CTest) +enable_testing() + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) + +include(CPack) + +find_package (PkgConfig REQUIRED) +pkg_check_modules (GTK3 REQUIRED gtk+-3.0) +include_directories (${GTK3_INCLUDE_DIRS}) +link_directories (${GTK3_LIBRARY_DIRS}) +add_executable(gtk89 src/main.cpp src/resources.cpp) +add_definitions (${GTK3_CFLAGS_OTHER}) +target_link_libraries (${PROJECT_NAME} ${GTK3_LIBRARIES}) diff --git a/Gtk3/gtk89_css_test/build_mingw.cmd b/Gtk3/gtk89_css_test/build_mingw.cmd new file mode 100644 index 0000000..e403f6c --- /dev/null +++ b/Gtk3/gtk89_css_test/build_mingw.cmd @@ -0,0 +1,4 @@ +cd build_mingw +mingw32-make +gtk87 +pause diff --git a/Gtk3/gtk89_css_test/res/compile-resource.sh b/Gtk3/gtk89_css_test/res/compile-resource.sh new file mode 100644 index 0000000..1703a0a --- /dev/null +++ b/Gtk3/gtk89_css_test/res/compile-resource.sh @@ -0,0 +1 @@ + glib-compile-resources gtk89.resource.xml --target=../src/resources.cpp --generate-source diff --git a/Gtk3/gtk89_css_test/res/css_accordion.css b/Gtk3/gtk89_css_test/res/css_accordion.css new file mode 100644 index 0000000..ce3346d --- /dev/null +++ b/Gtk3/gtk89_css_test/res/css_accordion.css @@ -0,0 +1,52 @@ +@import url("resource://css_accordion/reset.css"); + +* { + transition-property: color, background-color, border-color, background-image, padding, border-width; + transition-duration: 1s; + + font: 20px Cantarell; +} + +window { + background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0, + linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px, + linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px, + linear-gradient(333deg, #222, #222 5px, transparent 5px) 10px 10px, + linear-gradient(90deg, #1b1b1b, #1b1b1b 10px, transparent 10px), + linear-gradient(#1d1d1d, #1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424); + background-color: #131313; + background-size: 20px 20px; +} + +button { + color: black; + background-color: #bbb; + border-style: solid; + border-width: 2px 0 2px 2px; + border-color: #333; + + padding: 12px 4px; +} + +button:first-child { + border-radius: 5px 0 0 5px; +} + +button:last-child { + border-radius: 0 5px 5px 0; + border-width: 2px; +} + +button:hover { + padding: 12px 48px; + background-color: #4870bc; +} + +button *:hover { + color: white; +} + +button:hover:active, +button:active { + background-color: #993401; +} diff --git a/Gtk3/gtk89_css_test/res/gtk89.resource.xml b/Gtk3/gtk89_css_test/res/gtk89.resource.xml new file mode 100644 index 0000000..7c9c57d --- /dev/null +++ b/Gtk3/gtk89_css_test/res/gtk89.resource.xml @@ -0,0 +1,7 @@ + + + + css_accordion.css + reset.css + + diff --git a/Gtk3/gtk89_css_test/res/reset.css b/Gtk3/gtk89_css_test/res/reset.css new file mode 100644 index 0000000..7af3e7f --- /dev/null +++ b/Gtk3/gtk89_css_test/res/reset.css @@ -0,0 +1,11 @@ +/* @import this colorsheet to get the default values for every property. + * This is useful when writing special CSS tests that should not be + * inluenced by themes - not even the default ones. + * Keep in mind that the output will be very ugly and not look like + * anything GTK. + * Also, when adding new style properties, please add them here. + */ + +* { + all: unset; +} diff --git a/Gtk3/gtk89_css_test/src/main.cpp b/Gtk3/gtk89_css_test/src/main.cpp new file mode 100644 index 0000000..6394602 --- /dev/null +++ b/Gtk3/gtk89_css_test/src/main.cpp @@ -0,0 +1,51 @@ +#include + +static void apply_css (GtkWidget *widget, GtkStyleProvider *provider) +{ + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT); + if (GTK_IS_CONTAINER (widget)) + gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider); +} + +static void gtkmain(GtkApplication *app,gpointer user_data){ + GtkWidget *window,*container,*child; + window = gtk_application_window_new (app); + GtkStyleProvider *provider; + gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion"); + gtk_window_set_default_size (GTK_WINDOW (window), 600, 300); + + container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + gtk_widget_set_halign (container, GTK_ALIGN_CENTER); + gtk_widget_set_valign (container, GTK_ALIGN_CENTER); + gtk_container_add (GTK_CONTAINER (window), container); + + child = gtk_button_new_with_label ("This"); + gtk_container_add (GTK_CONTAINER (container), child); + + child = gtk_button_new_with_label ("Is"); + gtk_container_add (GTK_CONTAINER (container), child); + + child = gtk_button_new_with_label ("A"); + gtk_container_add (GTK_CONTAINER (container), child); + + child = gtk_button_new_with_label ("CSS"); + gtk_container_add (GTK_CONTAINER (container), child); + + child = gtk_button_new_with_label ("Accordion"); + gtk_container_add (GTK_CONTAINER (container), child); + + child = gtk_button_new_with_label (":-)"); + gtk_container_add (GTK_CONTAINER (container), child); + + provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); + gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider), "/css_accordion/css_accordion.css"); + + apply_css (window, provider); + gtk_widget_show_all (window); +} + +int main(int argc,char ** argv){ + GtkApplication *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/Gtkmm3/gtk90_css_test/CMakeLists.txt b/Gtkmm3/gtk90_css_test/CMakeLists.txt new file mode 100644 index 0000000..86d4850 --- /dev/null +++ b/Gtkmm3/gtk90_css_test/CMakeLists.txt @@ -0,0 +1,26 @@ +set(CMAKE_CXX_STANDARD 17) +cmake_minimum_required(VERSION 3.0.0) +project(gtk90 VERSION 0.1.0) + +include(CTest) +enable_testing() + +set(CPACK_PROJECT_NAME ${PROJECT_NAME}) +set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) + +include(CPack) +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(gtk90 src/main.cc src/resources.cpp) + +IF(WIN32) + SET(CMAKE_EXE_LINKER_FLAGS -mwindows) +ENDIF(WIN32) + +add_definitions (${GTKMM3_CFLAGS_OTHER}) +target_link_libraries (${PROJECT_NAME} ${GTKMM3_LIBRARIES}) diff --git a/Gtkmm3/gtk90_css_test/build_mingw.cmd b/Gtkmm3/gtk90_css_test/build_mingw.cmd new file mode 100644 index 0000000..092c16d --- /dev/null +++ b/Gtkmm3/gtk90_css_test/build_mingw.cmd @@ -0,0 +1,3 @@ +cd build_mingw +mingw32-make +gtk85 diff --git a/Gtkmm3/gtk90_css_test/res/compile-resource.sh b/Gtkmm3/gtk90_css_test/res/compile-resource.sh new file mode 100644 index 0000000..1703a0a --- /dev/null +++ b/Gtkmm3/gtk90_css_test/res/compile-resource.sh @@ -0,0 +1 @@ + glib-compile-resources gtk89.resource.xml --target=../src/resources.cpp --generate-source diff --git a/Gtkmm3/gtk90_css_test/res/css_accordion.css b/Gtkmm3/gtk90_css_test/res/css_accordion.css new file mode 100644 index 0000000..ce3346d --- /dev/null +++ b/Gtkmm3/gtk90_css_test/res/css_accordion.css @@ -0,0 +1,52 @@ +@import url("resource://css_accordion/reset.css"); + +* { + transition-property: color, background-color, border-color, background-image, padding, border-width; + transition-duration: 1s; + + font: 20px Cantarell; +} + +window { + background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0, + linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px, + linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px, + linear-gradient(333deg, #222, #222 5px, transparent 5px) 10px 10px, + linear-gradient(90deg, #1b1b1b, #1b1b1b 10px, transparent 10px), + linear-gradient(#1d1d1d, #1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424); + background-color: #131313; + background-size: 20px 20px; +} + +button { + color: black; + background-color: #bbb; + border-style: solid; + border-width: 2px 0 2px 2px; + border-color: #333; + + padding: 12px 4px; +} + +button:first-child { + border-radius: 5px 0 0 5px; +} + +button:last-child { + border-radius: 0 5px 5px 0; + border-width: 2px; +} + +button:hover { + padding: 12px 48px; + background-color: #4870bc; +} + +button *:hover { + color: white; +} + +button:hover:active, +button:active { + background-color: #993401; +} diff --git a/Gtkmm3/gtk90_css_test/res/gtk89.resource.xml b/Gtkmm3/gtk90_css_test/res/gtk89.resource.xml new file mode 100644 index 0000000..7c9c57d --- /dev/null +++ b/Gtkmm3/gtk90_css_test/res/gtk89.resource.xml @@ -0,0 +1,7 @@ + + + + css_accordion.css + reset.css + + diff --git a/Gtkmm3/gtk90_css_test/res/reset.css b/Gtkmm3/gtk90_css_test/res/reset.css new file mode 100644 index 0000000..7af3e7f --- /dev/null +++ b/Gtkmm3/gtk90_css_test/res/reset.css @@ -0,0 +1,11 @@ +/* @import this colorsheet to get the default values for every property. + * This is useful when writing special CSS tests that should not be + * inluenced by themes - not even the default ones. + * Keep in mind that the output will be very ugly and not look like + * anything GTK. + * Also, when adding new style properties, please add them here. + */ + +* { + all: unset; +} diff --git a/Gtkmm3/gtk90_css_test/src/main.cc b/Gtkmm3/gtk90_css_test/src/main.cc new file mode 100644 index 0000000..13523a1 --- /dev/null +++ b/Gtkmm3/gtk90_css_test/src/main.cc @@ -0,0 +1,63 @@ +#include + +class MyWin : public Gtk::Window{ +public: + MyWin() + :main_box(Gtk::ORIENTATION_HORIZONTAL,0) + { + //Initalize window + set_title("CSS Accordion"); + set_default_size(600,300); + set_icon_name("org.gtk.daleclack"); + //Initalize Box + main_box.set_halign(Gtk::ALIGN_CENTER); + main_box.set_valign(Gtk::ALIGN_CENTER); + + //Add Buttons + btn1.set_label("This"); + main_box.pack_start(btn1); + + btn2.set_label("Is"); + main_box.pack_start(btn2); + + btn3.set_label("A"); + main_box.pack_start(btn3); + + btn4.set_label("CSS"); + main_box.pack_start(btn4); + + btn5.set_label("Accordion"); + main_box.pack_start(btn5); + + btn6.set_label(":-)"); + main_box.pack_start(btn6); + + add(main_box); + + //Apply css theme + provider=Gtk::CssProvider::create(); + provider->load_from_resource("/css_accordion/css_accordion.css"); + main_box.forall(sigc::mem_fun(*this,&MyWin::apply_css)); + style=get_style_context(); + style->add_provider(provider,G_MAXUINT); + + show_all_children(); + } +private: + //Child Widgets + Gtk::Box main_box; + Gtk::Button btn1,btn2,btn3,btn4,btn5,btn6; + Glib::RefPtr provider; + Glib::RefPtr style; + //Apply CSS for each widget + void apply_css(Gtk::Widget &widget){ + auto style1=widget.get_style_context(); + style1->add_provider(provider,G_MAXUINT); + } +}; + +int main(int argc,char **argv){ + auto app=Gtk::Application::create(argc,argv,"org.gtk.daleclack"); + MyWin window; + return app->run(window); +} diff --git a/icon-install/org.gtk.daleclack.desktop b/icon-install/org.gtk.daleclack.desktop index 84bf1e3..cb8ad13 100644 --- a/icon-install/org.gtk.daleclack.desktop +++ b/icon-install/org.gtk.daleclack.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Name=Gtk4-test -Exec=/mnt/Dell/testing-repository/Gtk4/gtk4-test/bin/gtk4-test +Exec=/bin/sh Comment= Terminal=false Icon=org.gtk.daleclack diff --git a/icon-install/~/.local/share/applications/org.gtk.daleclack.desktop b/icon-install/~/.local/share/applications/org.gtk.daleclack.desktop new file mode 100644 index 0000000..90ac586 --- /dev/null +++ b/icon-install/~/.local/share/applications/org.gtk.daleclack.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Gtk4-test +Exec=/bin/sh +Comment= +Terminal=false +Icon=org.gtk.daleclack +Type=Application +X-Desktop-File-Install-Version=0.26