# Path: kano/gtk3/icons.py
# def set_from_name(name):
# 
# Path: kano/gtk3/cursor.py
# def attach_cursor_events(button):
#     button.connect('enter-notify-event', hand_cursor)
#     button.connect('leave-notify-event', arrow_cursor)
#     button.connect('button-press-event', arrow_cursor)
# 
# 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'


from gi import require_version
from gi.repository import Gtk
from kano.gtk3 import icons
from kano.gtk3.cursor import attach_cursor_events
from kano.paths import common_css_dir
import os
import sys


TOP_BAR_HEIGHT = 44
HEADER_WIDTH = 100


class TopBar(Gtk.EventBox):
    def __init__(self, title, window_width=-1, has_buttons=True):

        Gtk.EventBox.__init__(self)

        self.has_buttons = has_buttons

        # Styling
        self.cssProvider = Gtk.CssProvider()
        top_bar_css = os.path.join(common_css_dir, 'top_bar.css')
        if not os.path.exists(top_bar_css):
            sys.exit('CSS file missing!')
        self.cssProvider.load_from_path(top_bar_css)
        styleContext = self.get_style_context()
        styleContext.add_provider(self.cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)

        self.set_size_request(window_width, TOP_BAR_HEIGHT)

        self.height = TOP_BAR_HEIGHT

        self.header = Gtk.Label(title, halign=Gtk.Align.CENTER)
        self.align_header = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0)
        self.align_header.add(self.header)


# Path: kano/gtk3/icons.py
# def set_from_name(name):
# 
# Path: kano/gtk3/cursor.py
# def attach_cursor_events(button):
#     button.connect('enter-notify-event', hand_cursor)
#     button.connect('leave-notify-event', arrow_cursor)
#     button.connect('button-press-event', arrow_cursor)
# 
# 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/top_bar.py
from gi import require_version
from gi.repository import Gtk
from kano.gtk3 import icons
from kano.gtk3.cursor import attach_cursor_events
from kano.paths import common_css_dir
import os
import sys



TOP_BAR_HEIGHT = 44
HEADER_WIDTH = 100


class TopBar(Gtk.EventBox):
    def __init__(self, title, window_width=-1, has_buttons=True):

        Gtk.EventBox.__init__(self)

        self.has_buttons = has_buttons

        # Styling
        self.cssProvider = Gtk.CssProvider()
        top_bar_css = os.path.join(common_css_dir, 'top_bar.css')
        if not os.path.exists(top_bar_css):
            sys.exit('CSS file missing!')
        self.cssProvider.load_from_path(top_bar_css)
        styleContext = self.get_style_context()
        styleContext.add_provider(self.cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)

        self.set_size_request(window_width, TOP_BAR_HEIGHT)

        self.height = TOP_BAR_HEIGHT

        self.header = Gtk.Label(title, halign=Gtk.Align.CENTER)
        self.align_header = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0)
        self.align_header.add(self.header)


        self.cross = icons.set_from_name("cross")