dimanche 12 janvier 2020

how to set size for the indicator of a Gtk# checkbutton widget?

Plz, can someone tell me how to change the size of the white square(the indicator?) of a checkbutton in gtk#? The api said,

GtkCheckButton:indicator-size has been deprecated since version 3.20 and should not be used in newly-written code. Use CSS min-width and min-height on the indicator node.

But what is this "on the indicator node" referring to? How to change the size of the indicator now? BTW, I am writing C# on linux (monodevelop):

    static void Main()
    {
        Gtk.CssProvider cssProvider= new CssProvider();
        cssProvider.LoadFromPath("style.css"); //connect to a css file defining the checkbutton's style property

        Application.Init();
        Gtk.Window win = new Gtk.Window("hello");
        win.SetDefaultSize(600,240);
        win.StyleContext.AddProvider(cssProvider,1);



        Gtk.HeaderBar win_title_bar = new HeaderBar();
        Gtk.Label title_bar_title = new Label();
        title_bar_title.Markup = "<span font-size=\"14000\"><b>PLZ Help!</b></span>";
        title_bar_title.MarginStart = 10;
        win_title_bar.PackStart(title_bar_title);
        win_title_bar.ShowCloseButton = true;
        win.Titlebar = win_title_bar;


        Gtk.VBox main_vbox = new VBox();
        win.Add(main_vbox);

        Gtk.Label lbl1 = new Label();
        lbl1.Name = "lbl1";
        lbl1.Markup = "<span font-size=\"12000\">lbl of the checkbutton</span>";
        lbl1.MarginStart = 10;
        Gtk.CheckButton chk1 = new CheckButton();
        chk1.Name = "chk1";
        chk1.Add(lbl1);

        chk1.StyleContext.AddProvider(cssProvider, 1);//telling chk1 to read the style code in style.css

        Gtk.Alignment chk_align = new Alignment(0.5f,0f,0,0);
        chk_align.Add(chk1);
        main_vbox.PackStart(chk_align, false, false, 0);

        win.DeleteEvent += delete_event;
        win.ShowAll();
        Application.Run();
    }


    static void delete_event(object obj, DeleteEventArgs args)
    {
        Console.WriteLine("Quit");
        Application.Quit();
    }

The following style.css is the syntax I have been trying out, but none of them worked. I put them all together in here.

checkbutton indicator {
    min-width:30px;
    min-height:30px;    
}

checkbutton:indicator {
    min-width:30px;
    min-height:30px;    
}

.indicator {
    min-width:30px;
    min-height:30px;    
}

checkbutton check {
    min-width:30px;
    min-height:30px;    
}

check {
    min-width:30px;
    min-height:30px;    
}

indicator {
    min-width:30px;
    min-height:30px;    
}

Plz! Help!!!




Aucun commentaire:

Enregistrer un commentaire