Add Css Tests
This commit is contained in:
parent
869cd57132
commit
b02daadb4d
|
@ -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})
|
|
@ -0,0 +1,4 @@
|
|||
cd build_mingw
|
||||
mingw32-make
|
||||
gtk87
|
||||
pause
|
|
@ -0,0 +1 @@
|
|||
glib-compile-resources gtk89.resource.xml --target=../src/resources.cpp --generate-source
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/css_accordion">
|
||||
<file>css_accordion.css</file>
|
||||
<file>reset.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -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})
|
|
@ -0,0 +1,3 @@
|
|||
cd build_mingw
|
||||
mingw32-make
|
||||
gtk85
|
|
@ -0,0 +1 @@
|
|||
glib-compile-resources gtk89.resource.xml --target=../src/resources.cpp --generate-source
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/css_accordion">
|
||||
<file>css_accordion.css</file>
|
||||
<file>reset.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
#include <gtkmm.h>
|
||||
|
||||
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<Gtk::CssProvider> provider;
|
||||
Glib::RefPtr<Gtk::StyleContext> 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);
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue