예제 #1
0
    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        scrolled_window = Gtk.ScrolledWindow()
        self.webview = webview = WebKit.WebView()
        scrolled_window.add(webview)
        webview.show()
        vbox.pack_start(scrolled_window, True, True, 0)
        scrolled_window.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-gallery", self.save_gallery)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(),
                                    "html/index.html")
        self.webview.load_uri('file://' + web_app_page)

        # Display all
        self.set_canvas(vbox)
        vbox.show()
예제 #2
0
파일: activity.py 프로젝트: cemeiq/Primero
    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        self.webview = webview  = WebKit.WebView()
        webview.show()
        vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-context", self.save_context)
        self.enyo.connect("refresh-screen", self.refresh)
        self.enyo.connect("set_categories", self.set_categories)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

        # Display all
        self.set_canvas(vbox)
        vbox.show()
예제 #3
0
    def make_mainview(self):
        "Create the activity view"
        # Create global box
        vbox = Gtk.VBox(False)

        # Create webview
        self.webview = webview = WebKit.WebView()

        # Create console for debug (set to True)
        self.showconsole = False
        if self.showconsole:
            swv = Gtk.ScrolledWindow()
            swv.add(webview)
            webview.show()
            vbox.pack_start(swv, True, True, 0)
            swv.set_size_request(800, 700)
            swv.show()

            sw = Gtk.ScrolledWindow()
            self.consoleview = textview = Gtk.TextView()
            self.console = console = textview.get_buffer()
            sw.add(textview)
            sw.show()
            textview.show()
            sw.set_size_request(800, 100)

            vbox.pack_end(sw, True, True, 0)
        else:
            webview.show()
            vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("console-message", self.console_message)
        self.enyo.connect("save-context", self.save_context)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(),
                                    "html/index.html")
        self.webview.load_uri('file://' + web_app_page)

        # Display all
        self.set_canvas(vbox)
        vbox.show()
예제 #4
0
class GridpaintActivity(activity.Activity):
    """GridpaintActivity class as specified in activity.info"""
    def __init__(self, handle):
        """Set up the activity."""
        activity.Activity.__init__(self, handle)

        self.max_participants = 1

        self.make_toolbar()
        self.make_mainview()

        self.context = None

    def init_context(self, args):
        self.enyo.send_message("load-gallery", self.context)

    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        scrolled_window = Gtk.ScrolledWindow()
        self.webview = webview = WebKit.WebView()
        scrolled_window.add(webview)
        webview.show()
        vbox.pack_start(scrolled_window, True, True, 0)
        scrolled_window.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-gallery", self.save_gallery)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(),
                                    "html/index.html")
        self.webview.load_uri('file://' + web_app_page)

        # Display all
        self.set_canvas(vbox)
        vbox.show()

    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)
        share_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

    def write_file(self, file_path):
        "Called when activity is saved, get the current context in Enyo"
        if self.context is None:
            return
        self.file_path = file_path
        file = open(self.file_path, 'w')
        try:
            file.write(self.context['gallery'] + '\n')
            file.write(self.context['mode'] + '\n')
            file.write(str(self.context['selected']) + '\n')
        finally:
            file.close()

    def save_gallery(self, context):
        "Called by JavaScript to save the current gallery"
        self.context = context

    def read_file(self, file_path):
        "Called when activity is loaded, load the current context in the file"
        file = open(file_path, 'r')
        self.context = None
        try:
            gallery = file.readline().strip('\n')
            mode = file.readline().strip('\n')
            selected = file.readline().strip('\n')
            self.context = {
                'gallery': gallery,
                'mode': mode,
                'selected': selected
            }
        finally:
            file.close()
예제 #5
0
파일: activity.py 프로젝트: cemeiq/Primero
class EnyoActivity(activity.Activity):
    """EnyoActivity class as specified in activity.info"""

    def __init__(self, handle):
        """Set up the activity."""
        activity.Activity.__init__(self, handle)

        self.max_participants = 1
        self.context = {}

        self.favorite_status = 'notfavorite'
        self.filter_status = ''

        self.make_toolbar()
        self.make_mainview()

    def filter_changed(self, button):
        if self.filter_status == button.get_label():
            self.filter_status = ''
        else:
            self.filter_status = button.get_label()
        self.enyo.send_message("filter_clicked", self.filter_status)

    def favorite(self, button):
        if self.favorite_status == 'favorite':
            self.favorite_button.icon_name = self.favorite_status = 'notfavorite'
            self.enyo.send_message("favorite_clicked", 0)
        else:
            self.favorite_button.icon_name = self.favorite_status = 'favorite'
            self.enyo.send_message("favorite_clicked", 1)

    def text_filter(self, entry):
        self.enyo.send_message("text_typed", entry.props.text)

    def library_clicked(self, button):
        self.enyo.send_message("library_clicked")

    def refresh(self, context):
        self.context = context
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

    def init_context(self, args):
        """Init Javascript context sending buddy information"""
        # Get XO colors
        buddy = {}
        client = gconf.client_get_default()
        colors = client.get_string("/desktop/sugar/user/color")
        buddy["colors"] = colors.split(",")

        # Get XO name
        presenceService = presenceservice.get_instance()
        buddy["name"] = presenceService.get_owner().props.nick

        self.enyo.send_message("buddy", buddy)
        if self.context != {}:
            self.enyo.send_message("load-context", self.context)
        else:
            self.enyo.send_message("library_clicked")

    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        self.webview = webview  = WebKit.WebView()
        webview.show()
        vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-context", self.save_context)
        self.enyo.connect("refresh-screen", self.refresh)
        self.enyo.connect("set_categories", self.set_categories)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

        # Display all
        self.set_canvas(vbox)
        vbox.show()

    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        self.toolbarview = Gtk.Toolbar()
        langtoolbar_button = ToolbarButton(
            label=_('Filter'),
            page=self.toolbarview,
            icon_name='filter')
        langtoolbar_button.show()
        toolbar_box.toolbar.insert(langtoolbar_button, -1)
        self.toolbarview.show()

        box_search_item = Gtk.ToolItem()
        self.search_entry = Gtk.Entry()
        self.search_entry.connect('changed', self.text_filter)
        self.search_entry.set_size_request(300, -1)
        box_search_item.add(self.search_entry)
        self.search_entry.show()
        box_search_item.show()
        toolbar_box.toolbar.insert(box_search_item, -1)

        favorite_button = ToolButton(self.favorite_status)
        favorite_button.set_tooltip('Filter on favorite')
        favorite_button.connect('clicked', self.favorite)
        toolbar_box.toolbar.insert(favorite_button, -1)
        favorite_button.show()
        self.favorite_button = favorite_button

        library_button = ToolButton('library')
        library_button.set_tooltip('Show libraries')
        library_button.connect('clicked', self.library_clicked)
        toolbar_box.toolbar.insert(library_button, -1)
        library_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

    def set_categories(self, categories):
        """Called when Enyo load a new database with new categories, udate the filter"""
        nitems = self.toolbarview.get_n_items()
        for i in range(0, nitems):
            self.toolbarview.remove(self.toolbarview.get_nth_item(0))
        for category in categories:
            btn = Gtk.Button.new_with_label(category['id'])
            btn.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.1568, 0.1568, 0.1568, 1.0))
            btn.connect('clicked', self.filter_changed)
            btn.show()
            tool = Gtk.ToolItem()
            tool.add(btn)
            tool.show()
            self.toolbarview.insert(tool, -1)
        self.toolbarview.show()

    def write_file(self, file_path):
        """Called when activity is saved, get the current context in Enyo"""
        self.file_path = file_path
        self.enyo.send_message("save-context")

    def save_context(self, context):
        """Called by Enyo to save the current context"""
        file = open(self.file_path, 'w')
        try:
            file.write(self.enyo.json_encode(context)+'\n')
        finally:
            file.close()

    def read_file(self, file_path):
        """Called when activity is loaded, load the current context in the file"""
        file = open(file_path, 'r')
        self.context = {}
        try:
            self.context = self.enyo.json_decode(file.readline().strip('\n'))
        finally:
            file.close()
예제 #6
0
class EnyoActivity(activity.Activity):
    """EnyoActivity class as specified in activity.info"""
    def __init__(self, handle):
        """Set up the activity."""
        activity.Activity.__init__(self, handle)

        self.max_participants = 1
        self.context = {}

        self.favorite_status = 'notfavorite'

        self.make_toolbar()
        self.make_mainview()

    def language_en(self, button):
        self.enyo.send_message("language_clicked", "en")

    def language_es(self, button):
        self.enyo.send_message("language_clicked", "es")

    def language_fr(self, button):
        self.enyo.send_message("language_clicked", "fr")

    def favorite(self, button):
        if self.favorite_status == 'favorite':
            self.favorite_button.icon_name = self.favorite_status = 'notfavorite'
            self.enyo.send_message("favorite_clicked", 0)
        else:
            self.favorite_button.icon_name = self.favorite_status = 'favorite'
            self.enyo.send_message("favorite_clicked", 1)

    def refresh(self, context):
        self.context = context
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page + "?onsugar=1")

    def settings(self, button):
        self.enyo.send_message("settings_clicked")

    def init_context(self, args):
        """Init Javascript context sending buddy information"""
        # Get XO colors
        buddy = {}
        client = gconf.client_get_default()
        colors = client.get_string("/desktop/sugar/user/color")
        buddy["colors"] = colors.split(",")

        # Get XO name
        presenceService = presenceservice.get_instance()
        buddy["name"] = presenceService.get_owner().props.nick

        self.enyo.send_message("buddy", buddy)
        if self.context != {}:
            self.enyo.send_message("load-context", self.context)

    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        self.webview = webview = WebKit.WebView()
        webview.show()
        vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-context", self.save_context)
        self.enyo.connect("refresh-screen", self.refresh)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page + "?onsugar=1")

        # Display all
        self.set_canvas(vbox)
        vbox.show()

    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        toolbarview = Gtk.Toolbar()
        langtoolbar_button = ToolbarButton(label=_('View'),
                                           page=toolbarview,
                                           icon_name='settings')
        langtoolbar_button.show()
        toolbar_box.toolbar.insert(langtoolbar_button, -1)
        tool = ToolButton('en')
        tool.set_tooltip(_('English'))
        tool.connect('clicked', self.language_en)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('es')
        tool.set_tooltip(_('Spanish'))
        tool.connect('clicked', self.language_es)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('fr')
        tool.set_tooltip(_('French'))
        tool.connect('clicked', self.language_fr)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('remote')
        tool.set_tooltip(_('Server settings'))
        tool.connect('clicked', self.settings)
        tool.show()
        toolbarview.insert(tool, -1)
        toolbarview.show()

        favorite_button = ToolButton(self.favorite_status)
        favorite_button.set_tooltip('Filter on favorite')
        favorite_button.connect('clicked', self.favorite)
        toolbar_box.toolbar.insert(favorite_button, -1)
        favorite_button.show()
        self.favorite_button = favorite_button

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

    def write_file(self, file_path):
        """Called when activity is saved, get the current context in Enyo"""
        self.file_path = file_path
        self.enyo.send_message("save-context")

    def save_context(self, context):
        """Called by Enyo to save the current context"""
        file = open(self.file_path, 'w')
        try:
            file.write(self.enyo.json_encode(context) + '\n')
        finally:
            file.close()

    def read_file(self, file_path):
        """Called when activity is loaded, load the current context in the file"""
        file = open(file_path, 'r')
        self.context = {}
        try:
            self.context = self.enyo.json_decode(file.readline().strip('\n'))
        finally:
            file.close()
예제 #7
0
class EnyoActivity(activity.Activity):
    """EnyoActivity class as specified in activity.info"""

    def __init__(self, handle):
        """Set up the activity."""
        activity.Activity.__init__(self, handle)

        self.max_participants = 1
        self.context = {}

        self.favorite_status = 'notfavorite'

        self.make_toolbar()
        self.make_mainview()

    def language_en(self, button):
        self.enyo.send_message("language_clicked", "en")

    def language_es(self, button):
        self.enyo.send_message("language_clicked", "es")

    def language_fr(self, button):
        self.enyo.send_message("language_clicked", "fr")

    def favorite(self, button):
        if self.favorite_status == 'favorite':
            self.favorite_button.icon_name = self.favorite_status = 'notfavorite'
            self.enyo.send_message("favorite_clicked", 0)
        else:
            self.favorite_button.icon_name = self.favorite_status = 'favorite'
            self.enyo.send_message("favorite_clicked", 1)

    def refresh(self, context):
        self.context = context
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

    def settings(self, button):
        self.enyo.send_message("settings_clicked")

    def init_context(self, args):
        """Init Javascript context sending buddy information"""
        # Get XO colors
        buddy = {}
        client = gconf.client_get_default()
        colors = client.get_string("/desktop/sugar/user/color")
        buddy["colors"] = colors.split(",")

        # Get XO name
        presenceService = presenceservice.get_instance()
        buddy["name"] = presenceService.get_owner().props.nick

        self.enyo.send_message("buddy", buddy)
        if self.context != {}:
            self.enyo.send_message("load-context", self.context)

    def make_mainview(self):
        """Create the activity view"""
        # Create global box
        vbox = Gtk.VBox(True)

        # Create webview
        self.webview = webview  = WebKit.WebView()
        webview.show()
        vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("save-context", self.save_context)
        self.enyo.connect("refresh-screen", self.refresh)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(), "index.html")
        self.webview.load_uri('file://' + web_app_page+"?onsugar=1")

        # Display all
        self.set_canvas(vbox)
        vbox.show()

    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        toolbarview = Gtk.Toolbar()
        langtoolbar_button = ToolbarButton(
            label=_('View'),
            page=toolbarview,
            icon_name='settings')
        langtoolbar_button.show()
        toolbar_box.toolbar.insert(langtoolbar_button, -1)
        tool = ToolButton('en')
        tool.set_tooltip(_('English'))
        tool.connect('clicked', self.language_en)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('es')
        tool.set_tooltip(_('Spanish'))
        tool.connect('clicked', self.language_es)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('fr')
        tool.set_tooltip(_('French'))
        tool.connect('clicked', self.language_fr)
        tool.show()
        toolbarview.insert(tool, -1)
        tool = ToolButton('remote')
        tool.set_tooltip(_('Server settings'))
        tool.connect('clicked', self.settings)
        tool.show()
        toolbarview.insert(tool, -1)
        toolbarview.show()

        favorite_button = ToolButton(self.favorite_status)
        favorite_button.set_tooltip('Filter on favorite')
        favorite_button.connect('clicked', self.favorite)
        toolbar_box.toolbar.insert(favorite_button, -1)
        favorite_button.show()
        self.favorite_button = favorite_button

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

    def write_file(self, file_path):
        """Called when activity is saved, get the current context in Enyo"""
        self.file_path = file_path
        self.enyo.send_message("save-context")

    def save_context(self, context):
        """Called by Enyo to save the current context"""
        file = open(self.file_path, 'w')
        try:
            file.write(self.enyo.json_encode(context)+'\n')
        finally:
            file.close()

    def read_file(self, file_path):
        """Called when activity is loaded, load the current context in the file"""
        file = open(file_path, 'r')
        self.context = {}
        try:
            self.context = self.enyo.json_decode(file.readline().strip('\n'))
        finally:
            file.close()
예제 #8
0
class AbecedariumActivity(activity.Activity):
    "Main class for the activity"

    def __init__(self, handle):
        """Set up the activity."""
        self.context = {}
        self.enyo = None
        self.showconsole = False
        activity.Activity.__init__(self, handle)

        self.max_participants = 1

        self.make_toolbar()
        self.make_mainview()

    def alert(self, msg):
        """Display a message dialog"""
        messagedialog = Gtk.MessageDialog(self,
                                          type=1,
                                          buttons=1,
                                          message_format=msg)
        messagedialog.run()
        messagedialog.destroy()

    def console_message(self, message):
        if not self.showconsole:
            return
        self.console.set_text(
            self.console.get_text(self.console.get_start_iter(),
                                  self.console.get_end_iter(), True) +
            message + "\n")
        self.consoleview.scroll_mark_onscreen(self.console.get_insert())

    def init_context(self, args):
        "Init Javascript context sending information about localization and saved game"
        self.enyo.send_message("load-context", self.context)

    def make_mainview(self):
        "Create the activity view"
        # Create global box
        vbox = Gtk.VBox(False)

        # Create webview
        self.webview = webview = WebKit.WebView()

        # Create console for debug (set to True)
        self.showconsole = False
        if self.showconsole:
            swv = Gtk.ScrolledWindow()
            swv.add(webview)
            webview.show()
            vbox.pack_start(swv, True, True, 0)
            swv.set_size_request(800, 700)
            swv.show()

            sw = Gtk.ScrolledWindow()
            self.consoleview = textview = Gtk.TextView()
            self.console = console = textview.get_buffer()
            sw.add(textview)
            sw.show()
            textview.show()
            sw.set_size_request(800, 100)

            vbox.pack_end(sw, True, True, 0)
        else:
            webview.show()
            vbox.pack_start(webview, True, True, 0)
        vbox.show()

        # Activate Enyo interface
        self.enyo = Enyo(webview)
        self.enyo.connect("ready", self.init_context)
        self.enyo.connect("console-message", self.console_message)
        self.enyo.connect("save-context", self.save_context)

        # Go to first page
        web_app_page = os.path.join(activity.get_bundle_path(),
                                    "html/index.html")
        self.webview.load_uri('file://' + web_app_page)

        # Display all
        self.set_canvas(vbox)
        vbox.show()

    def make_toolbar(self):
        # toolbar with the new toolbar redesign
        toolbar_box = ToolbarBox()

        activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(activity_button, 0)
        activity_button.show()

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

        description_item = DescriptionItem(self)
        toolbar_box.toolbar.insert(description_item, -1)
        description_item.show()

        share_button = ShareButton(self)
        toolbar_box.toolbar.insert(share_button, -1)
        share_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

    def write_file(self, file_path):
        "Called when activity is saved, get the current context in Enyo"
        self.file_path = file_path
        self.enyo.send_message("save-context")

    def save_context(self, context):
        "Called by Enyo to save the current context"
        file = open(self.file_path, 'w')
        try:
            file.write(context['context'] + '\n')
            file.write(context['database'] + '\n')
        finally:
            file.close()

    def read_file(self, file_path):
        "Called when activity is loaded, load the current context in the file"
        file = open(file_path, 'r')
        self.context = {}
        try:
            self.context['context'] = file.readline().strip('\n')
            self.context['database'] = file.readline().strip('\n')
        finally:
            file.close()