diff --git a/libmalcontent-ui/malcontent-ui.gresource.xml b/libmalcontent-ui/malcontent-ui.gresource.xml index cbdaa9f..089d8a5 100644 --- a/libmalcontent-ui/malcontent-ui.gresource.xml +++ b/libmalcontent-ui/malcontent-ui.gresource.xml @@ -4,6 +4,7 @@ restrict-applications-dialog.ui restrict-applications-selector.ui + restricts-switch.css user-controls.ui diff --git a/libmalcontent-ui/restricts-switch.css b/libmalcontent-ui/restricts-switch.css new file mode 100644 index 0000000..c44debe --- /dev/null +++ b/libmalcontent-ui/restricts-switch.css @@ -0,0 +1,18 @@ +/* FIXME: This ‘negative’ variant of a GtkSwitch should probably be + * upstreamed to GTK. See https://gitlab.gnome.org/GNOME/gtk/issues/2470 */ +switch:checked.restricts { + background-color: @error_color; +} + +switch:checked.restricts, switch:checked.restricts slider { + border-color: #8b0000; +} + +switch:disabled.restricts { + border-color: @borders; + background-color: @insensitive_bg_color; +} + +switch:disabled.restricts slider { + border-color: #bfb8b1; +} diff --git a/libmalcontent-ui/user-controls.c b/libmalcontent-ui/user-controls.c index 080eb95..5326df4 100644 --- a/libmalcontent-ui/user-controls.c +++ b/libmalcontent-ui/user-controls.c @@ -949,12 +949,20 @@ mct_user_controls_init (MctUserControls *self) { g_autoptr(GDBusConnection) system_bus = NULL; g_autoptr(GError) error = NULL; + g_autoptr(GtkCssProvider) provider = NULL; /* Ensure the types used in the UI are registered. */ g_type_ensure (MCT_TYPE_RESTRICT_APPLICATIONS_DIALOG); gtk_widget_init_template (GTK_WIDGET (self)); + provider = gtk_css_provider_new (); + gtk_css_provider_load_from_resource (provider, + "/org/freedesktop/MalcontentUi/ui/restricts-switch.css"); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1); + self->selected_age = (guint) -1; self->cancellable = g_cancellable_new ();