# Path: kano_world/functions.py
# def get_mixed_username():
#     if is_registered():
#         import mercury  # Lazy import to avoid dynamically linking with global import
#         kw = mercury.KanoWorld(kw_url)
#         username = kw.get_username()
#     else:
#         username = get_user_unsudoed()
#     return username
# 
# Path: kano_profile/badges.py
# def calculate_kano_level():
#     '''
#     Calculates the current level of the user
#     Returns: level, percentage and current xp
#     '''
#     level_rules = read_json(levels_file)
#     if not level_rules:
#         return -1, 0, 0
# 
#     max_level = max([int(n) for n in level_rules.keys()])
#     xp_now = calculate_xp()
# 
#     for level in xrange(1, max_level + 1):
#         level_min = level_rules[str(level)]
# 
#         if level != max_level:
#             level_max = level_rules[str(level + 1)] - 1
#         else:
#             level_max = float('inf')
# 
#         if level_min <= xp_now <= level_max:
#             reached_level = level
#             reached_percentage = (xp_now - level_min) / (level_max + 1 - level_min)
# 
#             return int(reached_level), reached_percentage, xp_now
# 
# Path: kano_profile_gui/components/icons.py
# def get_ui_icon(name):
#     if name == 'green_arrow':
#         icon_number = 0
#     elif name == 'pale_right_arrow':
#         icon_number = 1
#     elif name == 'dark_left_arrow':
#         icon_number = 2
#     elif name == 'dark_right_arrow':
#         icon_number = 3
#     elif name == 'pale_left_arrow':
#         icon_number = 4
#     elif name == 'tick':
#         icon_number = 5
#     elif name == 'cross':
#         icon_number = 6
#     elif name == 'dropdown_arrow':
#         icon_number = 7
#     else:
#         raise Exception('Unknown icon name ' + name)
# 
#     src_loc = os.path.join(media_dir, 'images/icons/systemsetup-icons.png')
#     pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(src_loc, 192, 24)
# 
#     subpixbuf = pixbuf.new_subpixbuf(24 * icon_number, 0, 24, 24)
#     buf = subpixbuf.add_alpha(True, 255, 255, 255)
# 
#     icon = Gtk.Image()
#     icon.set_from_pixbuf(buf)
#     return icon


import os
from gi.repository import Gtk, GObject
from kano.gtk3.cursor import attach_cursor_events
from kano_world.functions import get_mixed_username
from kano_profile.badges import calculate_kano_level
from kano_profile_gui.components.icons import get_ui_icon
            button = MenuButton(_(name), self._quests)
            button.connect('clicked', self.emit_menu_signal, name)
            button.connect('clicked', self.set_selected_wrapper, name)
            hbox.pack_end(button, False, False, 0)

            # add to the self.buttons dictionary
            self.buttons[name] = {}
            self.buttons[name]['button'] = button

            if name == MenuBar.QUESTS_STR:
                # check the notification image
                button.check_for_notification()

            # HACKY: avoiding packing the label divider after the last element
            if name != MenuBar.CHARACTER_STR:
                label = self._create_divider_label()
                hbox.pack_end(label, False, False, 0)

            attach_cursor_events(button)

        # initialise with the CHARACTER button selected
        self.set_selected(self.CHARACTER_STR)

    def _create_divider_label(self):
        label = Gtk.Label("|")
        label.get_style_context().add_class('button_divider')
        return label

    def _create_cross_button(self):
        # Close button

# Path: kano_world/functions.py
# def get_mixed_username():
#     if is_registered():
#         import mercury  # Lazy import to avoid dynamically linking with global import
#         kw = mercury.KanoWorld(kw_url)
#         username = kw.get_username()
#     else:
#         username = get_user_unsudoed()
#     return username
# 
# Path: kano_profile/badges.py
# def calculate_kano_level():
#     '''
#     Calculates the current level of the user
#     Returns: level, percentage and current xp
#     '''
#     level_rules = read_json(levels_file)
#     if not level_rules:
#         return -1, 0, 0
# 
#     max_level = max([int(n) for n in level_rules.keys()])
#     xp_now = calculate_xp()
# 
#     for level in xrange(1, max_level + 1):
#         level_min = level_rules[str(level)]
# 
#         if level != max_level:
#             level_max = level_rules[str(level + 1)] - 1
#         else:
#             level_max = float('inf')
# 
#         if level_min <= xp_now <= level_max:
#             reached_level = level
#             reached_percentage = (xp_now - level_min) / (level_max + 1 - level_min)
# 
#             return int(reached_level), reached_percentage, xp_now
# 
# Path: kano_profile_gui/components/icons.py
# def get_ui_icon(name):
#     if name == 'green_arrow':
#         icon_number = 0
#     elif name == 'pale_right_arrow':
#         icon_number = 1
#     elif name == 'dark_left_arrow':
#         icon_number = 2
#     elif name == 'dark_right_arrow':
#         icon_number = 3
#     elif name == 'pale_left_arrow':
#         icon_number = 4
#     elif name == 'tick':
#         icon_number = 5
#     elif name == 'cross':
#         icon_number = 6
#     elif name == 'dropdown_arrow':
#         icon_number = 7
#     else:
#         raise Exception('Unknown icon name ' + name)
# 
#     src_loc = os.path.join(media_dir, 'images/icons/systemsetup-icons.png')
#     pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(src_loc, 192, 24)
# 
#     subpixbuf = pixbuf.new_subpixbuf(24 * icon_number, 0, 24, 24)
#     buf = subpixbuf.add_alpha(True, 255, 255, 255)
# 
#     icon = Gtk.Image()
#     icon.set_from_pixbuf(buf)
#     return icon


# Path: kano_profile_gui/MenuBar.py
import os
from gi.repository import Gtk, GObject
from kano.gtk3.cursor import attach_cursor_events
from kano_world.functions import get_mixed_username
from kano_profile.badges import calculate_kano_level
from kano_profile_gui.components.icons import get_ui_icon

            button = MenuButton(_(name), self._quests)
            button.connect('clicked', self.emit_menu_signal, name)
            button.connect('clicked', self.set_selected_wrapper, name)
            hbox.pack_end(button, False, False, 0)

            # add to the self.buttons dictionary
            self.buttons[name] = {}
            self.buttons[name]['button'] = button

            if name == MenuBar.QUESTS_STR:
                # check the notification image
                button.check_for_notification()

            # HACKY: avoiding packing the label divider after the last element
            if name != MenuBar.CHARACTER_STR:
                label = self._create_divider_label()
                hbox.pack_end(label, False, False, 0)

            attach_cursor_events(button)

        # initialise with the CHARACTER button selected
        self.set_selected(self.CHARACTER_STR)

    def _create_divider_label(self):
        label = Gtk.Label("|")
        label.get_style_context().add_class('button_divider')
        return label

    def _create_cross_button(self):
        # Close button

        cross_icon = get_ui_icon('cross')