Skip to content

Commit

Permalink
add a 'force' option to the 'css_add' wrapper
Browse files Browse the repository at this point in the history
-enforce css overrides by loading as USER priority when absolutely
necessary (e.g. when a user override would compromise the resizing/
positioning calculations). doing this is no different to enforcing
styling via use of widget properties (e.g. margin) or style properties,
for which users obviously have zero influence upon
  • Loading branch information
elbeardmorez committed Mar 18, 2018
1 parent 84cdac1 commit 0c76d23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions quodlibet/quodlibet/qltk/__init__.py
Expand Up @@ -352,7 +352,7 @@ def is_accel(event, *accels):
return False


def add_css(widget, css):
def add_css(widget, css, force=False):
"""Add css for the widget, overriding the theme.
Can raise GLib.GError in case the css is invalid
Expand All @@ -364,7 +364,9 @@ def add_css(widget, css):
provider = Gtk.CssProvider()
provider.load_from_data(css)
context = widget.get_style_context()
context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
context.add_provider(provider,
Gtk.STYLE_PROVIDER_PRIORITY_USER if force else
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)


def remove_padding(widget):
Expand Down
12 changes: 6 additions & 6 deletions quodlibet/quodlibet/qltk/paned.py
Expand Up @@ -34,7 +34,7 @@ def ensure_wide_handle(self):
paned {
padding: 0px;
}
""")
""", True)
return

if hasattr(self.props, "wide_handle"):
Expand All @@ -46,7 +46,7 @@ def ensure_wide_handle(self):
border-width: 0;
background: none;
}
""")
""", True)
return

# gtk 3.14
Expand All @@ -57,7 +57,7 @@ def ensure_wide_handle(self):
margin: 0;
border-width: 0;
}
""")
""", True)

@property
def handle_size(self):
Expand Down Expand Up @@ -235,12 +235,12 @@ def __expander_widget(cls, xpaned, widget, allocated=False):
}
expander arrow {
padding: """ + str(__expander_spacing) + """px;
}""")
}""", True)
else:
add_css(widget, """
GtkExpander, expander {
-GtkExpander-expander-size: """ +
str(__expander_size) + "; }")
str(__expander_size) + "; }", True)

# common
add_css(widget, """
Expand All @@ -256,7 +256,7 @@ def __expander_widget(cls, xpaned, widget, allocated=False):
background-image: none;
margin: 0px;
padding: """ + str(__label_padding) + """px;
}""")
}""", True)

widget.title_size = title_size

Expand Down

0 comments on commit 0c76d23

Please sign in to comment.