kdg1955
kdg1955

Reputation: 325

GTK 3 how to select active tab of a notebook in a css file

This css code in ~/.config/gtk-3.0/gtk.css is functioning correctly :

.myNotebook .myTab  {
    border-width: 1px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border-style: groove;
}

.myNotebook .myTab:first-child  {
    background-color: yellow;
    border-style: solid;
}

But I only want to select the active tab (or focus tab?) and not all tabs.
Here is the code that I already tried and does not produce the desired result:

.myNotebook .myTab:first-child:select { ...}
.myNotebook .myTab:select { ...}
.myNotebook .myTab:first-child:select:focus { ...}
.myNotebook .myTab:select:focus { ...}
.myNotebook .myTab:first-child:select:active { ...}
.myNotebook .myTab:select:active { ...}
.myNotebook .myTab:first-child:active { ...}
.myNotebook .myTab:active { ...}
.myNotebook .myTab:first-child:focus { ...}
.myNotebook .myTab:focus { ...}
.myNotebook .myTab:first-child:active:focus { ...}
.myNotebook .myTab:active:focus { ...}

My program is written in c and I use glade as designer. Does anyone know the correct syntax?

Upvotes: 2

Views: 2121

Answers (1)

user5825851
user5825851

Reputation:

I was struggling with the same issue in a Python application today, and I simply tried every possible combination I could think of until I found one that worked. What worked in my case was tab:checked

Here is the full style set I used for a notebook named nbContent:

#nbContent > header.top {
    background: @colMedium;
    border-bottom: none;
}

#nbContent > header.top > tabs > tab {
    background: @colDark;
    color: @colText;
    border-image: none;
    border: 1px solid rgba(0,0,0,0.4);
    border-radius: 8px 8px 0px 0px;
    border-bottom: none;
}

#nbContent > header > tabs > tab:hover {
    background: @colLight;
    color: @colText;
    border-image: none;
}

#nbContent > header > tabs > tab:checked {
    background: @colLight;
    color: @colText;
    border-image: none;
}

Upvotes: 3

Related Questions