Esempio n. 1
0
 def view_source(self):
     """Implement the 'view source' key by saving pippy_app.py to the
     datastore, and then telling the Journal to view it."""
     if self.__source_object_id is None:
         from sugar import profile
         from sugar.datastore import datastore
         from sugar.activity.activity \
              import get_bundle_name, get_bundle_path
         from gettext import gettext as _
         import os.path
         jobject = datastore.create()
         metadata = {
             'title': _('%s Source') % get_bundle_name(),
             'title_set_by_user': '******',
             'suggested_filename': 'pippy_app.py',
             'icon-color': profile.get_color().to_string(),
             'mime_type': 'text/x-python',
             }
         for k, v in metadata.items():
             jobject.metadata[k] = v  # dict.update method is missing =(
         jobject.file_path = os.path.join(get_bundle_path(), 'pippy_app.py')
         datastore.write(jobject)
         self.__source_object_id = jobject.object_id
         jobject.destroy()
     self.journal_show_object(self.__source_object_id)
Esempio n. 2
0
 def beautifybutton_cb(self, button):
     self.save()
     butialo_app_name = '%s/tmp/butialo_app.lua' % self.get_activity_root()
     self._write_text_buffer(butialo_app_name)
     formatted = os.popen("./bobot/lua beaut.lua %s" % butialo_app_name)
     #formatted = "./lua codeformatter.lua --file %s" % butialo_app_name
     global text_buffer
     text_buffer.set_text(formatted.read())
     self.metadata['title'] = _('%s Activity') % get_bundle_name()
     self.stopbutton_cb(None)
     #self._reset_vte()
     self.text_view.grab_focus()
Esempio n. 3
0
 def view_source(self):
     """Implement the 'view source' key by saving 
     datastore, and then telling the Journal to view it."""
     if self.source_object_id is None:
         from sugar import profile
         from sugar.datastore import datastore
         from sugar.activity.activity import get_bundle_name, get_bundle_path
         from gettext import gettext as _
         import os.path
         jobject = datastore.create()
         metadata = {
             'title': _('%s Source') % get_bundle_name(),
             'title_set_by_user': '******',
             'suggested_filename': 'pippy_app.py',
             'icon-color': profile.get_color().to_string(),
             'mime_type': 'text/x-python',
             }
         for k,v in metadata.items():
             jobject.metadata[k] = v # dict.update method is missing =(
         jobject.file_path = os.path.join(get_bundle_path(), 'pippy_app.py')
         datastore.write(jobject)
         self.__source_object_id = jobject.object_id
         jobject.destroy()
     self.journal_show_object(self.__source_object_id)