예제 #1
0
파일: viewsource.py 프로젝트: svineet/sugar
 def __copy_to_home_cb(self, menu_item):
     """Make a local copy of the activity bundle in user_activities_path"""
     user_activities_path = get_user_activities_path()
     nick = customizebundle.generate_unique_id()
     new_basename = "%s_copy_of_%s" % (nick, os.path.basename(self._document_path))
     if not os.path.exists(os.path.join(user_activities_path, new_basename)):
         shutil.copytree(self._document_path, os.path.join(user_activities_path, new_basename), symlinks=True)
         customizebundle.generate_bundle(nick, new_basename)
     else:
         _logger.debug("%s already exists", new_basename)
예제 #2
0
 def __copy_to_home_cb(self, menu_item):
     """Make a local copy of the activity bundle in user_activities_path"""
     user_activities_path = get_user_activities_path()
     nick = customizebundle.generate_unique_id()
     new_basename = '%s_copy_of_%s' % (
         nick, os.path.basename(self._document_path))
     if not os.path.exists(os.path.join(user_activities_path,
                                        new_basename)):
         shutil.copytree(self._document_path,
                         os.path.join(user_activities_path, new_basename),
                         symlinks=True)
         customizebundle.generate_bundle(nick, new_basename)
     else:
         _logger.debug('%s already exists', new_basename)
예제 #3
0
    def __copy_to_home_cb(self, menu_item, copy_alert=None):
        """Make a local copy of the activity bundle in user_activities_path"""
        user_activities_path = get_user_activities_path()
        nick = customizebundle.generate_unique_id()
        new_basename = '%s_copy_of_%s' % (
            nick, os.path.basename(self._document_path))
        if not os.path.exists(os.path.join(user_activities_path,
                                           new_basename)):
            self.__set_busy_cursor(True)

            def async_copy_activity_tree():
                try:
                    shutil.copytree(self._document_path,
                                    os.path.join(
                                        user_activities_path,
                                        new_basename),
                                    symlinks=True)
                    customizebundle.generate_bundle(nick, new_basename)

                    if copy_alert:
                        self.get_toplevel().remove_alert(copy_alert)

                    alert = NotifyAlert(10)
                    alert.props.title = _('Duplicated')
                    alert.props.msg = _('The activity has been duplicated')
                    alert.connect('response', self.__alert_response_cb)
                    self.get_toplevel().add_alert(alert)
                finally:
                    self.__set_busy_cursor(False)

            GLib.idle_add(async_copy_activity_tree)
        else:
            if copy_alert:
                self.get_toplevel().remove_alert(copy_alert)

            self.__set_busy_cursor(False)

            alert = NotifyAlert(10)
            alert.props.title = _('Duplicated activity already exists')
            alert.props.msg = _('Delete your copy before trying to duplicate'
                                ' the activity again')

            alert.connect('response', self.__alert_response_cb)
            self.get_toplevel().add_alert(alert)
예제 #4
0
    def __copy_to_home_cb(self, menu_item, copy_alert=None):
        """Make a local copy of the activity bundle in user_activities_path"""
        user_activities_path = get_user_activities_path()
        nick = customizebundle.generate_unique_id()
        new_basename = '%s_copy_of_%s' % (
            nick, os.path.basename(self._document_path))
        if not os.path.exists(os.path.join(user_activities_path,
                                           new_basename)):
            self.__set_busy_cursor(True)

            def async_copy_activity_tree():
                try:
                    shutil.copytree(self._document_path,
                                    os.path.join(
                                        user_activities_path,
                                        new_basename),
                                    symlinks=True)
                    customizebundle.generate_bundle(nick, new_basename)

                    if copy_alert:
                        self.get_toplevel().remove_alert(copy_alert)

                    alert = NotifyAlert(10)
                    alert.props.title = _('Duplicated')
                    alert.props.msg = _('The activity has been duplicated')
                    alert.connect('response', self.__alert_response_cb)
                    self.get_toplevel().add_alert(alert)
                finally:
                    self.__set_busy_cursor(False)

            GLib.idle_add(async_copy_activity_tree)
        else:
            if copy_alert:
                self.get_toplevel().remove_alert(copy_alert)

            self.__set_busy_cursor(False)

            alert = NotifyAlert(10)
            alert.props.title = _('Duplicated activity already exists')
            alert.props.msg = _('Delete your copy before trying to duplicate'
                                ' the activity again')

            alert.connect('response', self.__alert_response_cb)
            self.get_toplevel().add_alert(alert)