# Path: kano/gtk3/buttons.py
# class KanoButton(GenericButton):
#     BUTTON_CSS = os.path.join(common_css_dir, 'kano_button.css')
#     SPINNER_CSS = os.path.join(common_css_dir, 'spinner.css')
# 
#     def __init__(self, text="", color="green", icon_filename=""):
# 
#         # Keep this updated - useful for set_color function
#         self.available_colors = ["orange", "green", "red", "grey", "blue"]
# 
#         # Create button
#         GenericButton.__init__(self, text, icon_filename)
# 
#         style_context = self.get_style_context()
#         style_context.add_class("kano_button")
#         style_context.add_class("kano_button_padding")
#         style_context.add_class(color + "_background")
# 
#         self.align = None
#         cursor.attach_cursor_events(self)
# 
#         self.add_spinner()
# 
#         widgets = [self, self.label]
#         for w in widgets:
#             apply_colours_to_widget(w)
#             apply_styling_to_widget(w, self.BUTTON_CSS)
# 
#     def pack(self):
#         self.box = Gtk.Box()
#         self.box.add(self)
# 
#     # Pakcing in a box and within an Alignment
#     def pack_and_align(self):
# 
#         # This stops the button resizing to fit the size of its container
#         self.box = Gtk.Box()
#         self.box.add(self)
#         self.props.halign = Gtk.Align.CENTER
#         self.box.props.halign = Gtk.Align.CENTER
# 
#         # This allows us to set our padding
#         self.align = Gtk.Alignment(xscale=0, yscale=0)
#         self.align.add(self.box)
# 
#     def set_padding(self, top, bottom, left, right):
#         if self.align is not None:
#             self.align.set_padding(top, bottom, left, right)
# 
#     def set_color(self, color):
#         for c in self.available_colors:
#             self.get_style_context().remove_class(c + "_background")
#         self.get_style_context().add_class(color + "_background")
# 
#     def set_margin(self, top_margin, right_margin, bottom_margin, left_margin):
#         self.set_margin_left(left_margin)
#         self.set_margin_right(right_margin)
#         self.set_margin_top(top_margin)
#         self.set_margin_bottom(bottom_margin)
# 
#     def add_spinner(self):
#         self.spinner = Gtk.Spinner()
#         self.spinner.props.active = True
#         self.is_spinning = False
#         apply_styling_to_widget(self.spinner, self.SPINNER_CSS)
# 
#     def start_spinner(self):
#         if self.is_spinning:
#             return
# 
#         # Keep old dimensions with box
#         allocation = self.get_allocation()
#         self.remove(self.internal_box)
#         self.add(self.spinner)
#         self.set_size_request(allocation.width, allocation.height)
# 
#         # Stops background going grey on making kano button insensitive,
#         # and controls styling of spinner
#         self.get_style_context().add_class("loading_kano_button")
# 
#         self.is_spinning = True
#         self.show_all()
#         self.spinner.start()
# 
#     # Replace content of button with original content and stop spinner spinning
#     def stop_spinner(self):
#         if not self.is_spinning:
#             return
# 
#         self.spinner.stop()
#         self.remove(self.spinner)
#         self.add(self.internal_box)
#         self.get_style_context().remove_class("loading_kano_button")
#         self.is_spinning = False
# 
# 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)


from gi import require_version
from gi.repository import Gtk
from kano.gtk3.buttons import KanoButton
from kano.gtk3.apply_styles import apply_styling_to_widget
# Copyright (C) 2016 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# An overlay to add blur effect
#

require_version('Gtk', '3.0')




class BlurOverlay(Gtk.Overlay):

    def __init__(self):
        Gtk.Overlay.__init__(self)

        self._loading = False

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._spinner = Gtk.Spinner()
        self._spinner.props.active = True
        apply_styling_to_widget(self._spinner, KanoButton.SPINNER_CSS)

    def _add_blur(self):
        self.add_overlay(self._blur)
        self._blur.show()

    def _rm_blur(self):

# Path: kano/gtk3/buttons.py
# class KanoButton(GenericButton):
#     BUTTON_CSS = os.path.join(common_css_dir, 'kano_button.css')
#     SPINNER_CSS = os.path.join(common_css_dir, 'spinner.css')
# 
#     def __init__(self, text="", color="green", icon_filename=""):
# 
#         # Keep this updated - useful for set_color function
#         self.available_colors = ["orange", "green", "red", "grey", "blue"]
# 
#         # Create button
#         GenericButton.__init__(self, text, icon_filename)
# 
#         style_context = self.get_style_context()
#         style_context.add_class("kano_button")
#         style_context.add_class("kano_button_padding")
#         style_context.add_class(color + "_background")
# 
#         self.align = None
#         cursor.attach_cursor_events(self)
# 
#         self.add_spinner()
# 
#         widgets = [self, self.label]
#         for w in widgets:
#             apply_colours_to_widget(w)
#             apply_styling_to_widget(w, self.BUTTON_CSS)
# 
#     def pack(self):
#         self.box = Gtk.Box()
#         self.box.add(self)
# 
#     # Pakcing in a box and within an Alignment
#     def pack_and_align(self):
# 
#         # This stops the button resizing to fit the size of its container
#         self.box = Gtk.Box()
#         self.box.add(self)
#         self.props.halign = Gtk.Align.CENTER
#         self.box.props.halign = Gtk.Align.CENTER
# 
#         # This allows us to set our padding
#         self.align = Gtk.Alignment(xscale=0, yscale=0)
#         self.align.add(self.box)
# 
#     def set_padding(self, top, bottom, left, right):
#         if self.align is not None:
#             self.align.set_padding(top, bottom, left, right)
# 
#     def set_color(self, color):
#         for c in self.available_colors:
#             self.get_style_context().remove_class(c + "_background")
#         self.get_style_context().add_class(color + "_background")
# 
#     def set_margin(self, top_margin, right_margin, bottom_margin, left_margin):
#         self.set_margin_left(left_margin)
#         self.set_margin_right(right_margin)
#         self.set_margin_top(top_margin)
#         self.set_margin_bottom(bottom_margin)
# 
#     def add_spinner(self):
#         self.spinner = Gtk.Spinner()
#         self.spinner.props.active = True
#         self.is_spinning = False
#         apply_styling_to_widget(self.spinner, self.SPINNER_CSS)
# 
#     def start_spinner(self):
#         if self.is_spinning:
#             return
# 
#         # Keep old dimensions with box
#         allocation = self.get_allocation()
#         self.remove(self.internal_box)
#         self.add(self.spinner)
#         self.set_size_request(allocation.width, allocation.height)
# 
#         # Stops background going grey on making kano button insensitive,
#         # and controls styling of spinner
#         self.get_style_context().add_class("loading_kano_button")
# 
#         self.is_spinning = True
#         self.show_all()
#         self.spinner.start()
# 
#     # Replace content of button with original content and stop spinner spinning
#     def stop_spinner(self):
#         if not self.is_spinning:
#             return
# 
#         self.spinner.stop()
#         self.remove(self.spinner)
#         self.add(self.internal_box)
#         self.get_style_context().remove_class("loading_kano_button")
#         self.is_spinning = False
# 
# 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)


# Path: kano/gtk3/blur_overlay.py
from gi import require_version
from gi.repository import Gtk
from kano.gtk3.buttons import KanoButton
from kano.gtk3.apply_styles import apply_styling_to_widget

# Copyright (C) 2016 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# An overlay to add blur effect
#

require_version('Gtk', '3.0')




class BlurOverlay(Gtk.Overlay):

    def __init__(self):
        Gtk.Overlay.__init__(self)

        self._loading = False

        self._blur = Gtk.EventBox()
        self._blur.get_style_context().add_class('blur')

        self._spinner = Gtk.Spinner()
        self._spinner.props.active = True
        apply_styling_to_widget(self._spinner, KanoButton.SPINNER_CSS)

    def _add_blur(self):
        self.add_overlay(self._blur)
        self._blur.show()

    def _rm_blur(self):

        self.remove(self._blur)