# Path: kano_wifi_gui/paths.py

# 
# Path: kano_wifi_gui/SpinnerScreen.py
# class SpinnerScreen(Gtk.Box):
# 
#     # wiface is only here to pass onto the ConnectWifi screen
#     def __init__(self, win, title, description,
#                  background_cb):
# 
#         self._win = win
#         self._win.top_bar.disable_prev()
#         self._wiface = self._win.wiface
#         self._title = title
#         self._description = description
#         self._background_cb = background_cb
# 
#         self._win.remove_main_widget()
# 
#         self.show_spinner_screen()
#         self.run_background_process()
# 
#     def show_spinner_screen(self):
#         Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
#         self.set_size_request(self._win.width, self._win.height)
# 
#         self._win.set_main_widget(self)
# 
#         heading = Heading(
#             self._title,
#             self._description,
#             self._win.is_plug()
#         )
#         self.pack_start(heading.container, False, False, 0)
# 
#         spinner = Gtk.Image()
# 
#         if self._win.is_plug():
#             filename = os.path.join(media_dir, "kano-wifi-gui/loading_bar.gif")
#         else:
#             filename = os.path.join(media_dir, "kano-wifi-gui/wifi-spinner-smaller.gif")
# 
#         anim = GdkPixbuf.PixbufAnimation.new_from_file(filename)
#         spinner.set_from_animation(anim)
# 
#         if self._win.is_plug():
#             # Added extra padding for the plug screen.
#             self.pack_start(spinner, False, False, 60)
#         else:
#             self.pack_start(spinner, False, False, 30)
# 
#         self._win.show_all()
# 
#     def run_background_process(self):
#         t = threading.Thread(target=self._background_cb)
#         t.start()
# 
# Path: kano_wifi_gui/Template.py
# class Template(Gtk.Box):
# 
#     def __init__(self, title, description, buttons, is_plug=False, img_path=None):
#         super(Template, self).__init__(orientation=Gtk.Orientation.VERTICAL)
#         self._focus_widget = None
# 
#         heading = Heading(
#             title,
#             description,
#             is_plug,
#             back_btn=False
#         )
#         bbox = Gtk.ButtonBox()
#         bbox.set_spacing(20)
#         bbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
#         bbox.set_margin_right(10)
#         bbox.set_margin_left(10)
# 
#         for b in buttons:
#             label = b["label"]
# 
#             if not label:
#                 gtk_button = Gtk.Label()
# 
#             else:
#                 button_type = b["type"]
#                 callback = b["callback"]
# 
#                 if button_type == "KanoButton":
#                     color = b["color"]
#                     gtk_button = KanoButton(label, color=color)
#                 elif button_type == "OrangeButton":
#                     gtk_button = OrangeButton(label)
# 
#                 gtk_button.connect("clicked", callback)
#             bbox.pack_start(gtk_button, False, False, 0)
# 
#             if "focus" in b:
#                 self._focus_widget = gtk_button
# 
#         self.pack_start(heading.container, False, False, 0)
#         heading.container.set_margin_right(15)
#         heading.container.set_margin_left(15)
# 
#         if img_path:
#             image = Gtk.Image.new_from_file(img_path)
# 
#         if is_plug:
#             self.pack_start(image, False, False, 10)
#             self.pack_start(bbox, False, False, 30)
#         else:
#             self.pack_start(image, False, False, 20)
#             self.pack_end(bbox, False, False, 30)
# 
#         self.show_all()
# 
#     def button_grab_focus(self):
#         if self._focus_widget is not None:
#             self._focus_widget.grab_focus()


import os
import threading
from gi import require_version
from gi.repository import Gtk, GObject
from kano.logging import logger
from kano.network import KwifiCache, connect
from kano.network import RC_CONNECTED, RC_BAD_PASSWORD, RC_AP_NOT_IN_RANGE, \
   RC_NO_DHCP_LEASE, RC_INCORRECT_PASSWORD_LEN, RC_INTERNAL_ERROR
from kano_wifi_gui.paths import img_dir
from kano_wifi_gui.SpinnerScreen import SpinnerScreen
from kano_wifi_gui.Template import Template
        from kano_wifi_gui.RefreshNetworks import RefreshNetworks
        from kano_wifi_gui.PasswordScreen import PasswordScreen
            {
                'label': _("QUIT"),
                'type': 'OrangeButton',
                'callback': Gtk.main_quit
            }
        ]
        img_path = os.path.join(img_dir, "no-wifi.png")

        self._win.set_main_widget(
            Template(
                title,
                description,
                buttons,
                self._win.is_plug(),
                img_path
            )
        )

    def _success_screen(self):
        self._win.remove_main_widget()
        title = _("Success")
        description = _("You're connected")
        buttons = [
            {
                'label': _("OK"),
                'type': 'KanoButton',
                'color': 'green',
                'callback': Gtk.main_quit
            }
        ]

# Path: kano_wifi_gui/paths.py

# 
# Path: kano_wifi_gui/SpinnerScreen.py
# class SpinnerScreen(Gtk.Box):
# 
#     # wiface is only here to pass onto the ConnectWifi screen
#     def __init__(self, win, title, description,
#                  background_cb):
# 
#         self._win = win
#         self._win.top_bar.disable_prev()
#         self._wiface = self._win.wiface
#         self._title = title
#         self._description = description
#         self._background_cb = background_cb
# 
#         self._win.remove_main_widget()
# 
#         self.show_spinner_screen()
#         self.run_background_process()
# 
#     def show_spinner_screen(self):
#         Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
#         self.set_size_request(self._win.width, self._win.height)
# 
#         self._win.set_main_widget(self)
# 
#         heading = Heading(
#             self._title,
#             self._description,
#             self._win.is_plug()
#         )
#         self.pack_start(heading.container, False, False, 0)
# 
#         spinner = Gtk.Image()
# 
#         if self._win.is_plug():
#             filename = os.path.join(media_dir, "kano-wifi-gui/loading_bar.gif")
#         else:
#             filename = os.path.join(media_dir, "kano-wifi-gui/wifi-spinner-smaller.gif")
# 
#         anim = GdkPixbuf.PixbufAnimation.new_from_file(filename)
#         spinner.set_from_animation(anim)
# 
#         if self._win.is_plug():
#             # Added extra padding for the plug screen.
#             self.pack_start(spinner, False, False, 60)
#         else:
#             self.pack_start(spinner, False, False, 30)
# 
#         self._win.show_all()
# 
#     def run_background_process(self):
#         t = threading.Thread(target=self._background_cb)
#         t.start()
# 
# Path: kano_wifi_gui/Template.py
# class Template(Gtk.Box):
# 
#     def __init__(self, title, description, buttons, is_plug=False, img_path=None):
#         super(Template, self).__init__(orientation=Gtk.Orientation.VERTICAL)
#         self._focus_widget = None
# 
#         heading = Heading(
#             title,
#             description,
#             is_plug,
#             back_btn=False
#         )
#         bbox = Gtk.ButtonBox()
#         bbox.set_spacing(20)
#         bbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
#         bbox.set_margin_right(10)
#         bbox.set_margin_left(10)
# 
#         for b in buttons:
#             label = b["label"]
# 
#             if not label:
#                 gtk_button = Gtk.Label()
# 
#             else:
#                 button_type = b["type"]
#                 callback = b["callback"]
# 
#                 if button_type == "KanoButton":
#                     color = b["color"]
#                     gtk_button = KanoButton(label, color=color)
#                 elif button_type == "OrangeButton":
#                     gtk_button = OrangeButton(label)
# 
#                 gtk_button.connect("clicked", callback)
#             bbox.pack_start(gtk_button, False, False, 0)
# 
#             if "focus" in b:
#                 self._focus_widget = gtk_button
# 
#         self.pack_start(heading.container, False, False, 0)
#         heading.container.set_margin_right(15)
#         heading.container.set_margin_left(15)
# 
#         if img_path:
#             image = Gtk.Image.new_from_file(img_path)
# 
#         if is_plug:
#             self.pack_start(image, False, False, 10)
#             self.pack_start(bbox, False, False, 30)
#         else:
#             self.pack_start(image, False, False, 20)
#             self.pack_end(bbox, False, False, 30)
# 
#         self.show_all()
# 
#     def button_grab_focus(self):
#         if self._focus_widget is not None:
#             self._focus_widget.grab_focus()


# Path: kano_wifi_gui/ConnectToNetwork.py
import os
import threading
from gi import require_version
from gi.repository import Gtk, GObject
from kano.logging import logger
from kano.network import KwifiCache, connect
from kano.network import RC_CONNECTED, RC_BAD_PASSWORD, RC_AP_NOT_IN_RANGE, \
   RC_NO_DHCP_LEASE, RC_INCORRECT_PASSWORD_LEN, RC_INTERNAL_ERROR
from kano_wifi_gui.paths import img_dir
from kano_wifi_gui.SpinnerScreen import SpinnerScreen
from kano_wifi_gui.Template import Template
        from kano_wifi_gui.RefreshNetworks import RefreshNetworks
        from kano_wifi_gui.PasswordScreen import PasswordScreen

            {
                'label': _("QUIT"),
                'type': 'OrangeButton',
                'callback': Gtk.main_quit
            }
        ]
        img_path = os.path.join(img_dir, "no-wifi.png")

        self._win.set_main_widget(
            Template(
                title,
                description,
                buttons,
                self._win.is_plug(),
                img_path
            )
        )

    def _success_screen(self):
        self._win.remove_main_widget()
        title = _("Success")
        description = _("You're connected")
        buttons = [
            {
                'label': _("OK"),
                'type': 'KanoButton',
                'color': 'green',
                'callback': Gtk.main_quit
            }
        ]

        img_path = os.path.join(img_dir, "internet.png")