# Path: kano/paths.py
# DNS_FILE = '/etc/resolvconf/resolv.conf.d/base'
# DNS_INTERFACES_FILE = '/etc/resolvconf/interface-order'
# DNS_INTERFACES_BACKUP_FILE = '/etc/resolvconf/interface-order.backup'
# SUPPLICANT_LOGFILE = '/var/log/kano_wpa.log'
# SUPPLICANT_CONFIG = '/etc/wpa_supplicant/wpa_supplicant.conf'
# INTERNET_UP_FILE = '/var/run/internet_monitor'
# KANO_CONNECT_PIDFILE = '/var/run/kano-connect.pid'
# 
# Path: kano/gtk3/apply_styles.py
# def apply_styling_to_widget(widget, path):
# 
#     if not os.path.exists(path):
#         sys.exit('{} CSS file missing!'.format(path))
# 
#     provider = Gtk.CssProvider()
#     provider.load_from_path(path)
#     styleContext = widget.get_style_context()
#     styleContext.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
# 
# def apply_styling_to_screen(css_file, priority="USER"):
#     css = Gtk.CssProvider()
# 
#     if not os.path.exists(css_file):
#         sys.exit(css_file + ' CSS file missing!')
# 
#     css.load_from_path(css_file)
# 
#     screen = Gdk.Screen.get_default()
#     styleContext = Gtk.StyleContext()
# 
#     if priority == "FALLBACK":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK
#     elif priority == "THEME":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_THEME
#     elif priority == "SETTINGS":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS
#     elif priority == "APPLICATION":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
#     elif priority == "USER":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_USER
# 
#     styleContext.add_provider_for_screen(screen, css, gtk_priority)
# 
# def apply_colours_to_widget(widget):
#     path = os.path.join(common_css_dir, "colours.css")
#     apply_styling_to_widget(widget, path)


from gi import require_version
from gi.repository import Gtk
from kano.paths import common_css_dir
from kano.gtk3.apply_styles import apply_styling_to_widget, apply_styling_to_screen, apply_colours_to_widget
import os
#
# Copyright (C) 2014 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
#
# Create a scrolled window with custom scrollbars
#

require_version('Gtk', '3.0')



class ScrolledWindow(Gtk.ScrolledWindow):
    NORMAL_CSS_PATH = os.path.join(common_css_dir, 'scrollbar.css')
    WIDE_CSS_PATH = os.path.join(common_css_dir, 'scrollbar-wide.css')

    def __init__(self, hexpand=None, vexpand=None, wide_scrollbar=False):
        Gtk.ScrolledWindow.__init__(self, hexpand=hexpand, vexpand=vexpand)
        self.set_overlay_scrolling(False)

    @staticmethod
    def apply_styling_to_screen(wide=False):
        if wide:
            apply_styling_to_screen(ScrolledWindow.WIDE_CSS_PATH)
        else:
            apply_styling_to_screen(ScrolledWindow.NORMAL_CSS_PATH)

    def apply_styling_to_widget(self, wide=False):
        for bar in [self.get_vscrollbar(), self.get_hscrollbar()]:
            apply_colours_to_widget(bar)
            if wide:

# Path: kano/paths.py
# DNS_FILE = '/etc/resolvconf/resolv.conf.d/base'
# DNS_INTERFACES_FILE = '/etc/resolvconf/interface-order'
# DNS_INTERFACES_BACKUP_FILE = '/etc/resolvconf/interface-order.backup'
# SUPPLICANT_LOGFILE = '/var/log/kano_wpa.log'
# SUPPLICANT_CONFIG = '/etc/wpa_supplicant/wpa_supplicant.conf'
# INTERNET_UP_FILE = '/var/run/internet_monitor'
# KANO_CONNECT_PIDFILE = '/var/run/kano-connect.pid'
# 
# Path: kano/gtk3/apply_styles.py
# def apply_styling_to_widget(widget, path):
# 
#     if not os.path.exists(path):
#         sys.exit('{} CSS file missing!'.format(path))
# 
#     provider = Gtk.CssProvider()
#     provider.load_from_path(path)
#     styleContext = widget.get_style_context()
#     styleContext.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
# 
# def apply_styling_to_screen(css_file, priority="USER"):
#     css = Gtk.CssProvider()
# 
#     if not os.path.exists(css_file):
#         sys.exit(css_file + ' CSS file missing!')
# 
#     css.load_from_path(css_file)
# 
#     screen = Gdk.Screen.get_default()
#     styleContext = Gtk.StyleContext()
# 
#     if priority == "FALLBACK":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK
#     elif priority == "THEME":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_THEME
#     elif priority == "SETTINGS":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS
#     elif priority == "APPLICATION":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
#     elif priority == "USER":
#         gtk_priority = Gtk.STYLE_PROVIDER_PRIORITY_USER
# 
#     styleContext.add_provider_for_screen(screen, css, gtk_priority)
# 
# def apply_colours_to_widget(widget):
#     path = os.path.join(common_css_dir, "colours.css")
#     apply_styling_to_widget(widget, path)


# Path: kano/gtk3/scrolled_window.py
from gi import require_version
from gi.repository import Gtk
from kano.paths import common_css_dir
from kano.gtk3.apply_styles import apply_styling_to_widget, apply_styling_to_screen, apply_colours_to_widget
import os

#
# Copyright (C) 2014 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
#
# Create a scrolled window with custom scrollbars
#

require_version('Gtk', '3.0')



class ScrolledWindow(Gtk.ScrolledWindow):
    NORMAL_CSS_PATH = os.path.join(common_css_dir, 'scrollbar.css')
    WIDE_CSS_PATH = os.path.join(common_css_dir, 'scrollbar-wide.css')

    def __init__(self, hexpand=None, vexpand=None, wide_scrollbar=False):
        Gtk.ScrolledWindow.__init__(self, hexpand=hexpand, vexpand=vexpand)
        self.set_overlay_scrolling(False)

    @staticmethod
    def apply_styling_to_screen(wide=False):
        if wide:
            apply_styling_to_screen(ScrolledWindow.WIDE_CSS_PATH)
        else:
            apply_styling_to_screen(ScrolledWindow.NORMAL_CSS_PATH)

    def apply_styling_to_widget(self, wide=False):
        for bar in [self.get_vscrollbar(), self.get_hscrollbar()]:
            apply_colours_to_widget(bar)
            if wide:

                apply_styling_to_widget(bar, self.WIDE_CSS_PATH)