res: almost able to load css

This commit is contained in:
Jeremy Attali 2019-12-16 00:39:24 -05:00
parent 35d4a0e158
commit 58aa1c4db4
5 changed files with 41 additions and 2 deletions

View File

@ -27,6 +27,7 @@ wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
subdir('res')
subdir('protocol')
executable(

12
res/meson.build Normal file
View File

@ -0,0 +1,12 @@
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
# Import the gnome module and use a GNOME function to ensure that application
# resources will be compiled.
gnome = import('gnome')
gnome.compile_resources('swappy',
'swappy.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)

3
res/style/popover.css Normal file
View File

@ -0,0 +1,3 @@
#popover .drawing {
font-family: 'Waybar';
}

6
res/swappy.gresource.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/swappy">
<file>style/popover.css</file>
</gresource>
</gresources>

View File

@ -182,7 +182,23 @@ static void draw_area_motion_notify_handler(GtkWidget *widget,
}
}
static bool build_ui(struct swappy_state *state) {
static void apply_css(GtkWidget *widget, GtkStyleProvider *provider) {
gtk_style_context_add_provider(gtk_widget_get_style_context(widget), provider,
1);
if (GTK_IS_CONTAINER(widget)) {
gtk_container_forall(GTK_CONTAINER(widget), (GtkCallback)apply_css,
provider);
}
}
static void load_css(struct swappy_state *state) {
GtkCssProvider *provider = gtk_css_provider_new();
gtk_css_provider_load_from_resource(provider, "/swappy/style/popover.css");
apply_css(GTK_WIDGET(state->popover), GTK_STYLE_PROVIDER(provider));
g_object_unref(provider);
}
static bool load_layout(struct swappy_state *state) {
GtkBuilder *builder;
GObject *container;
GObject *brush;
@ -288,7 +304,8 @@ static void init_layer_shell(GtkApplication *app, struct swappy_state *state) {
g_debug("window has sizes %dx%d", state->width, state->height);
build_ui(state);
load_layout(state);
load_css(state);
}
static gboolean is_geometry_valid(struct swappy_state *state) {