Change background color with gtkada css

Hi everyone and sorry again for the inconvenience but since then I have created a window with gtkada to which I want to change the color of the background with css, but this is where things get complicated for me. I can't import css into my program.

Here is my simple code :

File.ads


package file is

type abstract_type is abstract tagged null record;
Type my_window_record is new abstract_type with private;
type my_window is access all my_window_record'class;

procedure create_window (Window : my_window);

procedure open_window (window : my_window);

procedure style_window (window : my_window);

private

type my_window_record is new abstract_type with record

Win : Gtk_Window;
Provider : Gtk_Css_Provider;
Context : Gtk_Style_Context;

end record;
end file;

file.adb

package body file is

procedure create_window (window : my_window) is
begin

Gtk_New (Window.Win);
Window.Win.Fullscreen;
style_window (window);

end create_window;

procedure open_window (window : my_window ) is
begin

Window.Win.Show_All;

end open_window;

procedure style_window (window : my_window) is

      Error : aliased GError;
      Bool : aliased Boolean;
   begin
      
      Gtk_New (window.Provider);
      Gtk_New (window.Context);
      Bool := Load_From_Data (window.Provider,"style.css", Error'Access);
      Add_Provider (window.Context, + window.Provider, 0);

end style_window;

main.adb

procedure main is

win : my_window;

begin
Gtk.Main.Init;

win := new my_window_record;
create_window (Win);
open_window (Win);

Gtk.Main.Main;

end main;

When compiling everything goes well without any error messages. But the background color of the window has not changed. I would like to know why, or am I missing something?. And here is my very simple css code :

style.css

window {
         background-color: red;
}

anyone have an idea???

Upvotes: 0

Views: 91

Answers (0)

Related Questions