"proper" way to patch gnome-shell.css



Hi all,

I'm revisiting the first extension I ever wrote, which is meant to
override the `.panel-button` style class from gnome-shell.css to
change '-natural-hpadding' from 12px to 6px.

I'm trying to work out the "accepted" way to do this. I have managed
to get two methods working:

1) create a new St.Theme setting my extension's stylesheet to the top
priority like so:

    oldTheme = St.ThemeContext.get_for_stage(global.stage).get_theme();
    theme = new St.Theme({ application_stylesheet : my_extensions_stylesheet,
                                         theme_stylesheet       :
oldTheme.application_stylesheet,
                                         default_stylesheet      :
oldTheme.theme_stylesheet });
    theme.load_stylesheet( oldTheme.default_stylesheet );
    /* then load_stylesheet all of oldTheme.get_custom_stylesheets() */

That is, I put my extension's stylesheet.css with the highest priority
(all this has is `.panel-button { -natural-hpadding: 6px; }'), and
demote the old theme's stylesheets down a slot so that my stylesheet
overrides gnome-shell.css. (I notice that currently gnome-shell.css is
created in the application_stylesheet slot, and hence overrides any
other custom stylesheet).

2) listen to actor-added signal on Main.panel._rightBox and do a
`actor.set_style('-natural-hpadding: 6px')` which will override the
theme's styling as this one is inline styling.

Is either of these methods more "recommended" than the other? Will one
of the methods conflict if the user has their own custom theme
applied?

cheers.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]