# Path: linux_story/common.py
# def get_max_challenge_number():
#     '''
#     Returns:
#         str: string of the maximum challenge number as saved in
#             kano-profile.
#     '''
# 
#     # Hardcoded path, perhaps change it later
#     path = "/usr/share/kano-profile/rules/app_profiles.json"
#     f = open(path)
#     str_data = f.read()
#     f.close()
# 
#     dict_data = json.loads(str_data)
#     max_level = dict_data['linux-story']['max-level']
# 
#     return max_level
# 
# Path: linux_story/titles.py



from gi.repository import Gtk, GObject
from kano_profile.apps import load_app_state_variable
from linux_story.common import get_max_challenge_number
from linux_story.titles import challenges, chapters
# Shows the menu for selecting the appropriate challenge




class MenuScreen(Gtk.Alignment):
    '''This shows the user the challenges they can select.
    '''

    __gsignals__ = {
        # This returns an integer of the challenge the user wants to start from
        'challenge_selected': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
        'chapter_highlighted': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
        'challenge_highlighted': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
    }

    width = 500
    height = 200

    def __init__(self):
        Gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0, yscale=0)

        self.background = Gtk.EventBox()
        self.background.get_style_context().add_class("menu_background")
        self.background.set_size_request(self.width, self.height)

        self.add(self.background)

        # Find the greatest challenge that has been created according to
        # kano profile

# Path: linux_story/common.py
# def get_max_challenge_number():
#     '''
#     Returns:
#         str: string of the maximum challenge number as saved in
#             kano-profile.
#     '''
# 
#     # Hardcoded path, perhaps change it later
#     path = "/usr/share/kano-profile/rules/app_profiles.json"
#     f = open(path)
#     str_data = f.read()
#     f.close()
# 
#     dict_data = json.loads(str_data)
#     max_level = dict_data['linux-story']['max-level']
# 
#     return max_level
# 
# Path: linux_story/titles.py



# Path: linux_story/gtk3/MenuScreen.py
from gi.repository import Gtk, GObject
from kano_profile.apps import load_app_state_variable
from linux_story.common import get_max_challenge_number
from linux_story.titles import challenges, chapters

# Shows the menu for selecting the appropriate challenge




class MenuScreen(Gtk.Alignment):
    '''This shows the user the challenges they can select.
    '''

    __gsignals__ = {
        # This returns an integer of the challenge the user wants to start from
        'challenge_selected': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
        'chapter_highlighted': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
        'challenge_highlighted': (GObject.SIGNAL_RUN_FIRST, None, (int,)),
    }

    width = 500
    height = 200

    def __init__(self):
        Gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0, yscale=0)

        self.background = Gtk.EventBox()
        self.background.get_style_context().add_class("menu_background")
        self.background.set_size_request(self.width, self.height)

        self.add(self.background)

        # Find the greatest challenge that has been created according to
        # kano profile

        self.max_challenge = get_max_challenge_number()