diff --git a/meson.build b/meson.build index f1d3cc6..0ed0245 100644 --- a/meson.build +++ b/meson.build @@ -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( diff --git a/res/meson.build b/res/meson.build new file mode 100644 index 0000000..9436148 --- /dev/null +++ b/res/meson.build @@ -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, +) \ No newline at end of file diff --git a/res/style/popover.css b/res/style/popover.css new file mode 100644 index 0000000..50e959f --- /dev/null +++ b/res/style/popover.css @@ -0,0 +1,3 @@ +#popover .drawing { + font-family: 'Waybar'; +} \ No newline at end of file diff --git a/res/swappy.gresource.xml b/res/swappy.gresource.xml new file mode 100644 index 0000000..5709e87 --- /dev/null +++ b/res/swappy.gresource.xml @@ -0,0 +1,6 @@ + + + + style/popover.css + + \ No newline at end of file diff --git a/src/application.c b/src/application.c index 0c3cc83..17df9b3 100644 --- a/src/application.c +++ b/src/application.c @@ -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) {